Inheritance: System.Windows.Forms.Form
示例#1
0
        /// <summary>
        /// The default constructor
        /// </summary>
        public Actions()
        {
            StartPosition     = FormStartPosition.CenterScreen;
            Size              = new Size(790, 590);
            MinimumSize       = new Size(500, 375);
            Icon              = Data.Icon;
            Text              = Data.ProgramName;
            FormClosing      += new FormClosingEventHandler(Actions_FormClosing);
            Application.Idle += new EventHandler(Application_Idle);

            // Load a data file
            UpdateStatusLabel("Loading historical data...");
            if (LoadInstrument(false) != 0)
            {
                LoadInstrument(true);
                string messageText = Language.T("Forex Strategy Builder cannot load a historical data file and is going to use integrated data!");
                MessageBox.Show(messageText, Language.T("Data File Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            // Prepare custom indicators
            if (Configs.LoadCustomIndicators)
            {
                UpdateStatusLabel("Loading custom indicators...");
                Custom_Indicators.LoadCustomIndicators();
            }
            else
            {
                Indicator_Store.CombineAllIndicators();
            }

            // Load a strategy
            UpdateStatusLabel("Loading strategy...");
            string sStrategyPath = Data.StrategyPath;

            if (Configs.RememberLastStr && Configs.LastStrategy != "")
            {
                string sLastStrategy = Path.GetDirectoryName(Configs.LastStrategy);
                if (sLastStrategy != "")
                {
                    sLastStrategy = Configs.LastStrategy;
                }
                else
                {
                    string sPath = Path.Combine(Data.ProgramDir, Data.DefaultStrategyDir);
                    sLastStrategy = Path.Combine(sPath, Configs.LastStrategy);
                }
                if (File.Exists(sLastStrategy))
                {
                    sStrategyPath = sLastStrategy;
                }
            }

            if (OpenStrategy(sStrategyPath) == 0)
            {
                AfterStrategyOpening(false);
            }

            Calculate(false);

            Check_Update liveContent = new Check_Update(Data.SystemDir, miLiveContent, miForex);

            Registrar registrar = new Registrar();

            registrar.Register();

            // Starting tips
            if (Configs.ShowStartingTip)
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.Show();
            }

            UpdateStatusLabel("Loading user interface...");

            return;
        }
        /// <summary>
        /// The default constructor
        /// </summary>
        public Actions()
        {
            StartPosition     = FormStartPosition.CenterScreen;
            Size              = new Size(790, 590);
            MinimumSize       = new Size(500, 375);
            Icon              = Data.Icon;
            Text              = Data.ProgramName;
            FormClosing      += new FormClosingEventHandler(Actions_FormClosing);
            Application.Idle += new EventHandler(Application_Idle);

            // Load a data file
            UpdateStatusLabel("Loading historical data...");
            if (LoadInstrument(false) != 0)
            {
                LoadInstrument(true);
                string messageText = Language.T("Forex Strategy Builder cannot load a historical data file and is going to use integrated data!");
                MessageBox.Show(messageText, Language.T("Data File Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            // Prepare custom indicators
            if (Configs.LoadCustomIndicators)
            {
                UpdateStatusLabel("Loading custom indicators...");
                Custom_Indicators.LoadCustomIndicators();
            }
            else
                Indicator_Store.CombineAllIndicators();

            // Load a strategy
            UpdateStatusLabel("Loading strategy...");
            string sStrategyPath = Data.StrategyPath;

            if (Configs.RememberLastStr && Configs.LastStrategy != "")
            {
                string sLastStrategy = Path.GetDirectoryName(Configs.LastStrategy);
                if (sLastStrategy != "")
                    sLastStrategy = Configs.LastStrategy;
                else
                {
                    string sPath = Path.Combine(Data.ProgramDir, Data.DefaultStrategyDir);
                    sLastStrategy = Path.Combine(sPath, Configs.LastStrategy);
                }
                if (File.Exists(sLastStrategy))
                    sStrategyPath = sLastStrategy;
            }

            if (OpenStrategy(sStrategyPath) == 0)
            {
                AfterStrategyOpening(false);
            }

            Calculate(false);

            Check_Update liveContent = new Check_Update(Data.SystemDir, miLiveContent, miForex);

            Registrar registrar = new Registrar();
            registrar.Register();

            // Starting tips
            if (Configs.ShowStartingTip)
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.Show();
            }

            UpdateStatusLabel("Loading user interface...");

            return;
        }
        /// <summary>
        /// Opens the help window
        /// </summary>
        private void MenuHelpContentsOnClick(object sender, EventArgs e)
        {
            ToolStripMenuItem mi = (ToolStripMenuItem)sender;

            if ((string)mi.Tag == "tips")
            {
                Starting_Tips shv = new Starting_Tips();
                shv.Show();
                return;
            }

            try
            {
                System.Diagnostics.Process.Start((string)mi.Tag);
            }
            catch{ }

            return;
        }
示例#4
0
        /// <summary>
        /// Does the job
        /// </summary>
        void ParseInput(string input)
        {
            string[] asCommands = new string[]
            {
                "help           - Shows the commands list.",
                "clr            - Clears the screen.",
                "pos #          - Shows the parameters of position #.",
                "ord #          - Shows the parameters of order #.",
                "bar #          - Shows the prices of bar #.",
                "ind #          - Shows the indicators for bar #.",
                "str            - shows the strategy.",
                "debug          - Turns on debug mode.",
                "undebug        - Turns off debug mode.",
                "loadlang       - Reloads the language file.",
                "missingphrases - Shows all phrases, which are used in the program but are not included in the language file.",
                "genlangfiles   - Regenerates English.xml.",
                "repairlang     - Repairs all the language files.",
                "importlang     - Imports a translation (Read more first).",
                "langtowiki     - Shows translation in wiki format.",
                "resetinstrum   - Resets the instruments list.",
                "speedtest      - Performs a speed test.",
                "reloadtips     - Reloads the starting tips.",
                "showalltips    - Shows all the starting tips.",
            };

            if (input.StartsWith("help") || input.StartsWith("?"))
            {
                tbxOutput.Text = "Commands" + Environment.NewLine + "-----------------" + Environment.NewLine;
                foreach (string sCommand in asCommands)
                {
                    tbxOutput.Text += sCommand + Environment.NewLine;
                }
            }
            else if (input.StartsWith("clr"))
            {
                tbxOutput.Text = "";
            }
            else if (input.StartsWith("debug"))
            {
                tbxOutput.Text += "Debug mode - on" + Environment.NewLine;
                Data.Debug      = true;
            }
            else if (input.StartsWith("nodebug"))
            {
                tbxOutput.Text += "Debug mode - off" + Environment.NewLine;
                Data.Debug      = false;
            }
            else if (input.StartsWith("loadlang"))
            {
                Language.InitLanguages();
                tbxOutput.Text += "Language file loaded." + Environment.NewLine;
            }
            else if (input.StartsWith("importlang"))
            {
                Language.ImportLanguageFile(tbxOutput.Text);
            }
            else if (input.StartsWith("langtowiki"))
            {
                Language.ShowPhrases(4);
            }
            else if (input.StartsWith("genlangfiles"))
            {
                Language.GenerateLangFiles();
                tbxOutput.Text += "Language files generated." + Environment.NewLine;
            }
            else if (input.StartsWith("repairlang"))
            {
                tbxOutput.Text += "Language files repair" + Environment.NewLine + "---------------------" + Environment.NewLine + "";
                tbxOutput.Text += Language.RapairAllLangFiles();
            }
            else if (input.StartsWith("resetinstrum"))
            {
                Instruments.ResetInstruments();
                tbxOutput.Text += "The instruments are reset." + Environment.NewLine + "Restart the program now!" + Environment.NewLine;
            }
            else if (input.StartsWith("missingphrases"))
            {
                ShowMissingPhrases();
            }
            else if (input.StartsWith("speedtest"))
            {
                SpeedTest();
            }
            else if (input.StartsWith("str"))
            {
                ShowStrategy();
            }
            else if (input.StartsWith("pos"))
            {
                ShowPosition(input);
            }
            else if (input.StartsWith("ord"))
            {
                ShowOrder(input);
            }
            else if (input.StartsWith("bar"))
            {
                ShowBar(input);
            }
            else if (input.StartsWith("ind"))
            {
                ShowIndicators(input);
            }
            else if (input.StartsWith("reloadtips"))
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.Show();
            }
            else if (input.StartsWith("showalltips"))
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.ShowAllTips = true;
                startingTips.Show();
            }

            tbxOutput.Focus();
            tbxOutput.ScrollToCaret();

            tbxInput.Focus();
            tbxInput.Text = "";
            return;
        }
        /// <summary>
        /// Does the job
        /// </summary>
        void ParseInput(string input)
        {
            string[] asCommands = new string[]
            {
                "help           - Shows the commands list.",
                "clr            - Clears the screen.",
                "pos #          - Shows the parameters of position #.",
                "ord #          - Shows the parameters of order #.",
                "bar #          - Shows the prices of bar #.",
                "ind #          - Shows the indicators for bar #.",
                "str            - shows the strategy.",
                "debug          - Turns on debug mode.",
                "undebug        - Turns off debug mode.",
                "loadlang       - Reloads the language file.",
                "missingphrases - Shows all phrases, which are used in the program but are not included in the language file.",
                "genlangfiles   - Regenerates English.xml.",
                "repairlang     - Repairs all the language files.",
                "importlang     - Imports a translation (Read more first).",
                "langtowiki     - Shows translation in wiki format.",
                "resetinstrum   - Resets the instruments list.",
                "speedtest      - Performs a speed test.",
                "reloadtips     - Reloads the starting tips.",
                "showalltips    - Shows all the starting tips.",
            };

            if (input.StartsWith("help") || input.StartsWith("?"))
            {
                tbxOutput.Text = "Commands" + Environment.NewLine + "-----------------" + Environment.NewLine;
                foreach (string sCommand in asCommands)
                    tbxOutput.Text += sCommand + Environment.NewLine;
            }
            else if (input.StartsWith("clr"))
            {
                tbxOutput.Text = "";
            }
            else if (input.StartsWith("debug"))
            {
                tbxOutput.Text += "Debug mode - on" + Environment.NewLine;
                Data.Debug = true;
            }
            else if (input.StartsWith("nodebug"))
            {
                tbxOutput.Text += "Debug mode - off" + Environment.NewLine;
                Data.Debug = false;
            }
            else if (input.StartsWith("loadlang"))
            {
                Language.InitLanguages();
                tbxOutput.Text += "Language file loaded." + Environment.NewLine;
            }
            else if (input.StartsWith("importlang"))
            {
                Language.ImportLanguageFile(tbxOutput.Text);
            }
            else if (input.StartsWith("langtowiki"))
            {
                Language.ShowPhrases(4);
            }
            else if (input.StartsWith("genlangfiles"))
            {
                Language.GenerateLangFiles();
                tbxOutput.Text += "Language files generated." + Environment.NewLine;
            }
            else if (input.StartsWith("repairlang"))
            {
                tbxOutput.Text += "Language files repair" + Environment.NewLine + "---------------------" + Environment.NewLine + "";
                tbxOutput.Text += Language.RapairAllLangFiles();
            }
            else if (input.StartsWith("resetinstrum"))
            {
                Instruments.ResetInstruments();
                tbxOutput.Text += "The instruments are reset." + Environment.NewLine + "Restart the program now!" + Environment.NewLine;
            }
            else if (input.StartsWith("missingphrases"))
            {
                ShowMissingPhrases();
            }
            else if (input.StartsWith("speedtest"))
            {
                SpeedTest();
            }
            else if (input.StartsWith("str"))
            {
                ShowStrategy();
            }
            else if (input.StartsWith("pos"))
            {
                ShowPosition(input);
            }
            else if (input.StartsWith("ord"))
            {
                ShowOrder(input);
            }
            else if (input.StartsWith("bar"))
            {
                ShowBar(input);
            }
            else if (input.StartsWith("ind"))
            {
                ShowIndicators(input);
            }
            else if (input.StartsWith("reloadtips"))
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.Show();
            }
            else if (input.StartsWith("showalltips"))
            {
                Starting_Tips startingTips = new Starting_Tips();
                startingTips.ShowAllTips = true;
                startingTips.Show();
            }

            tbxOutput.Focus();
            tbxOutput.ScrollToCaret();

            tbxInput.Focus();
            tbxInput.Text = "";
            return;
        }