Пример #1
0
        //Allows the user to enter a new script that will be applied to all unlocked symbols
        private void cmdEditScript_Click(object sender, EventArgs e)
        {
            frmScannerScript settings = new frmScannerScript(this);

            TempScript          = Script;
            settings.HeaderText = "Script (will be applied to all unlocked symbols)";
            var result = settings.ShowDialog();

            if (result == DialogResult.Abort)
            {
                m_frmMain.OpenURL("http://www.modulusfe.com/TradeScript/TradeScript.pdf", "TradeScript Help");
                return;
            }
            if (result == DialogResult.OK)
            {
                Script = TempScript;
                //Apply script to each unlocked symbol
                for (int n = 0; n < grdResults.Rows.Count; n++)
                {
                    string symbol = grdResults.Rows[n].Cells["Symbol"].Value.ToString();
                    bool   locked = ((DataGridViewImageButtonCell)grdResults.Rows[n].Cells["Locked"]).Checked;
                    if (m_TSAlertDictionary.ContainsKey(symbol))
                    {
                        if (!locked) //This symbol's script isn't locked so change it
                        {
                            m_TSAlertDictionary[symbol].AlertScript = Script;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void oScript_ScriptError(string symbol, string alertName, string description)
        {
            if (m_loading || m_dialogShown)
            {
                return;
            }

            m_dialogShown = true;

            //Prevent the error from occuring over and over
            Alert oAlert = m_TSAlertDictionary[symbol];

            if (oAlert == null)
            {
                return;
            }

            //Find and highlight the record
            int row = -1;

            for (int n = 0; n < grdResults.Rows.Count; n++)
            {
                if (string.Compare(grdResults.Rows[n].Cells["Symbol"].Value.ToString(), symbol, true) == 0)
                {
                    row = n;
                    break;
                }
            }

            DataGridViewImageButtonCell cell = (DataGridViewImageButtonCell)grdResults.Rows[row].Cells["Start"];

            if (cell == null)
            {
                return;
            }

            TempScript = oAlert.AlertName;
            if (string.IsNullOrEmpty(oAlert.AlertName)) //if not already paused
            {
                TempScript         = oAlert.AlertScript;
                oAlert.AlertName   = oAlert.AlertScript; //Using AlertName as a Tag
                oAlert.AlertScript = string.Empty;       //Pause
                cell.Checked       = true;
            }

            // Display the error message
            if (!string.IsNullOrEmpty(oAlert.ScriptHelp))
            {
                if (MessageBox.Show("Your script generated an error: " + Environment.NewLine +
                                    description + Environment.NewLine +
                                    "Would you like to view help regarding this error?", "Error:",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    MessageBox.Show(oScript.ScriptHelp, symbol, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Your script generated an error:" + Environment.NewLine +
                                description, symbol, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            //Show edit dialog
            TempScript = string.IsNullOrEmpty(oAlert.AlertScript) ? oAlert.AlertName : oAlert.AlertScript;

            frmScannerScript settings = new frmScannerScript(this)
            {
                HeaderText = symbol + " Script"
            };
            DialogResult result = settings.ShowDialog();

            m_dialogShown = false;
            if (result == DialogResult.Abort)
            {
                m_frmMain.OpenURL("http://www.modulusfe.com/TradeScript/TradeScript.pdf", "TradeScript Help");
                return;
            }

            if (result == DialogResult.OK)
            {
                oAlert.AlertScript = TempScript;
                oAlert.AlertName   = string.Empty;
                cell.Checked       = false; //Script is runing now
            }
        }
Пример #3
0
        //Handles grid button clicks
        private void grdResults_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // this method handles only cell click
            // if e.RowIndex == -1 it means user clicked on header, so ignore this
            if (e.RowIndex == -1)
            {
                return;
            }

            try
            {
                string symbol = grdResults.SelectedRows[0].Cells["Symbol"].Value.ToString();
                Alert  oAlert = m_TSAlertDictionary[symbol];
                if (oAlert == null)
                {
                    return;
                }

                if (e.ColumnIndex == 5) //Trade
                {
                    grdResults.Rows[e.RowIndex].Selected = true;
                    //m_frmMain.EnterOrder(symbol);
                }
                else if (e.ColumnIndex == 6) //Chart
                {
                    EnableControls(true, false);
                    grdResults.Cursor = Cursors.WaitCursor;
                    grdResults.Rows[e.RowIndex].Selected = true;
                    ChartSelection selection = GetSelection(symbol);
                    m_frmMain.CreateNewCtlPainel(selection, new Action <CtlPainelChart>(chart => { }));
                    grdResults.Cursor = Cursors.Arrow;
                    EnableControls(true, true);
                }
                else if (e.ColumnIndex == 7) //Change the script for this individual alert
                {
                    TempScript = string.IsNullOrEmpty(oAlert.AlertScript)
                         ? oAlert.AlertName
                         : oAlert.AlertScript;
                    frmScannerScript settings = new frmScannerScript(this)
                    {
                        HeaderText = symbol + " Script"
                    };
                    var result = settings.ShowDialog();
                    if (result == DialogResult.Abort)
                    {
                        m_frmMain.OpenURL("http://www.modulusfe.com/TradeScript/TradeScript.pdf", "TradeScript Help");
                        return;
                    }
                    if (result == DialogResult.OK)
                    {
                        oAlert.AlertScript = TempScript;
                        oAlert.AlertName   = string.Empty;
                        DataGridViewImageButtonCell cell = (DataGridViewImageButtonCell)grdResults.Rows[e.RowIndex].Cells["Start"];
                        if (cell == null)
                        {
                            return;
                        }
                        cell.Checked = false; //Script is running now
                    }
                }//else if Column Index 7
                else if (e.ColumnIndex == 8) //Lock/unlock script to control effects of the "Edit Script" button
                {
                }
                else if (e.ColumnIndex == 9) //Play/pause
                {
                    DataGridViewImageButtonCell cell = (DataGridViewImageButtonCell)grdResults.Rows[e.RowIndex].Cells[e.ColumnIndex];
                    if (cell == null)
                    {
                        return;
                    }
                    bool pause = cell.Checked;
                    if (pause)
                    {
                        oAlert.AlertName   = oAlert.AlertScript; //Using AlertName as a Tag
                        oAlert.AlertScript = string.Empty;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(oAlert.AlertName)) //Play
                        {
                            oAlert.AlertScript = oAlert.AlertName;
                            oAlert.AlertName   = string.Empty;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }