Exemplo n.º 1
0
        /// <summary>
        /// Load Source Files
        /// </summary>
        public static void LoadCustomIndicators()
        {
            _indicatorManager = new IndicatorCompilationManager();

            if (!Directory.Exists(Data.SourceFolder))
            {
                MessageBox.Show("Custom indicators folder does not exist!", Language.T("Custom Indicators"));
                IndicatorStore.ResetCustomIndicators(null);
                IndicatorStore.CombineAllIndicators();
                return;
            }

            string[] pathInputFiles = Directory.GetFiles(Data.SourceFolder, "*.cs");
            if (pathInputFiles.Length == 0)
            {
                IndicatorStore.ResetCustomIndicators(null);
                IndicatorStore.CombineAllIndicators();
                return;
            }

            var errorReport = new StringBuilder();

            errorReport.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>");
            bool isError = false;

            foreach (string filePath in pathInputFiles)
            {
                string errorMessages;
                _indicatorManager.LoadCompileSourceFile(filePath, out errorMessages);

                if (!string.IsNullOrEmpty(errorMessages))
                {
                    isError = true;

                    errorReport.AppendLine("<h2>File name: " + Path.GetFileName(filePath) + "</h2>");
                    string error = errorMessages.Replace(Environment.NewLine, "</br>");
                    error = error.Replace("\t", "&nbsp; &nbsp; &nbsp;");
                    errorReport.AppendLine("<p>" + error + "</p>");
                }
            }

            // Adds the custom indicators
            IndicatorStore.ResetCustomIndicators(_indicatorManager.CustomIndicatorsList);
            IndicatorStore.CombineAllIndicators();

            if (isError)
            {
                var msgBox = new FancyMessageBox(errorReport.ToString(), Language.T("Custom Indicators"))
                {
                    BoxWidth = 550, BoxHeight = 340, TopMost = true
                };
                msgBox.Show();
            }

            if (Configs.ShowCustomIndicators)
            {
                ShowLoadedCustomIndicators();
            }
        }
        /// <summary>
        /// Load Source Files
        /// </summary>
        public static void LoadCustomIndicators()
        {
            _indicatorManager = new IndicatorCompilationManager();

            if (!Directory.Exists(Data.SourceFolder))
            {
                MessageBox.Show("Custom indicators folder does not exist!", Language.T("Custom Indicators"));
                IndicatorStore.ResetCustomIndicators(null);
                IndicatorStore.CombineAllIndicators();
                return;
            }

            string[] pathInputFiles = Directory.GetFiles(Data.SourceFolder, "*.cs");
            if (pathInputFiles.Length == 0)
            {
                IndicatorStore.ResetCustomIndicators(null);
                IndicatorStore.CombineAllIndicators();
                return;
            }

            var errorReport = new StringBuilder();
            errorReport.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>");
            bool isError = false;

            foreach (string filePath in pathInputFiles)
            {
                string errorMessages;
                _indicatorManager.LoadCompileSourceFile(filePath, out errorMessages);

                if (!string.IsNullOrEmpty(errorMessages))
                {
                    isError = true;

                    errorReport.AppendLine("<h2>File name: " + Path.GetFileName(filePath) + "</h2>");
                    string error = errorMessages.Replace(Environment.NewLine, "</br>");
                    error = error.Replace("\t", "&nbsp; &nbsp; &nbsp;");
                    errorReport.AppendLine("<p>" + error + "</p>");
                }
            }

            // Adds the custom indicators
            IndicatorStore.ResetCustomIndicators(_indicatorManager.CustomIndicatorsList);
            IndicatorStore.CombineAllIndicators();

            if (isError)
            {
                var msgBox = new FancyMessageBox(errorReport.ToString(), Language.T("Custom Indicators"))
                                 {BoxWidth = 550, BoxHeight = 340, TopMost = true};
                msgBox.Show();
            }

            if (Configs.ShowCustomIndicators)
                ShowLoadedCustomIndicators();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Test is finished
        /// </summary>
        private static void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var result = (CustomIndicatorsTestResult)e.Result;

            if (result.IsErrors)
            {
                var msgBoxError = new FancyMessageBox(result.ErrorReport, Language.T("Custom Indicators"))
                {
                    BoxWidth = 550, BoxHeight = 340, TopMost = true
                };
                msgBoxError.Show();
            }

            var msgBoxOK = new FancyMessageBox(result.OKReport, Language.T("Custom Indicators"))
            {
                BoxWidth = 350, BoxHeight = 280, TopMost = true
            };

            msgBoxOK.Show();
        }
        /// <summary>
        /// Calculates an indicator and returns OK status.
        /// </summary>
        private bool CalculateIndicator(SlotTypes type, Indicator indicator)
        {
            bool okStatus;

            try
            {
                indicator.Calculate(type);

                okStatus = true;
            }
            catch (Exception exception)
            {
                string request = "Please report this error in the support forum!";
                if (indicator.CustomIndicator)
                {
                    request = "Please report this error to the author of the indicator!<br />" +
                              "You may remove this indicator from the Custom Indicators folder.";
                }

                string text =
                    "<h1>Error: " + exception.Message + "</h1>" +
                    "<p>Slot type: <strong>" + type + "</strong><br />" +
                    "Indicator: <strong>" + indicator + "</strong></p>" +
                    "<p>" + request + "</p>";

                const string caption = "Indicator Calculation Error";
                var          msgBox  = new FancyMessageBox(text, caption)
                {
                    BoxWidth = 450, BoxHeight = 250
                };
                msgBox.Show();

                okStatus = false;
            }

            return(okStatus);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Shows the loaded custom indicators.
        /// </summary>
        private static void ShowLoadedCustomIndicators()
        {
            if (_indicatorManager.CustomIndicatorsList.Count == 0)
            {
                return;
            }

            var loadedIndicators = new StringBuilder();

            loadedIndicators.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>");
            loadedIndicators.AppendLine("<p>");
            foreach (Indicator indicator in _indicatorManager.CustomIndicatorsList)
            {
                loadedIndicators.AppendLine(indicator + "</br>");
            }
            loadedIndicators.AppendLine("</p>");

            var msgBox = new FancyMessageBox(loadedIndicators.ToString(), Language.T("Custom Indicators"))
            {
                BoxWidth = 480, BoxHeight = 260, TopMost = true
            };

            msgBox.Show();
        }
        /// <summary>
        /// Test is finished
        /// </summary>
        private static void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var result = (CustomIndicatorsTestResult) e.Result;

            if (result.IsErrors)
            {
                var msgBoxError = new FancyMessageBox(result.ErrorReport, Language.T("Custom Indicators"))
                                      {BoxWidth = 550, BoxHeight = 340, TopMost = true};
                msgBoxError.Show();
            }

            var msgBoxOK = new FancyMessageBox(result.OKReport, Language.T("Custom Indicators"))
                               {BoxWidth = 350, BoxHeight = 280, TopMost = true};
            msgBoxOK.Show();
        }
        /// <summary>
        /// Shows the loaded custom indicators.
        /// </summary>
        private static void ShowLoadedCustomIndicators()
        {
            if (_indicatorManager.CustomIndicatorsList.Count == 0)
                return;

            var loadedIndicators = new StringBuilder();
            loadedIndicators.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>");
            loadedIndicators.AppendLine("<p>");
            foreach (Indicator indicator in _indicatorManager.CustomIndicatorsList)
                loadedIndicators.AppendLine(indicator + "</br>");
            loadedIndicators.AppendLine("</p>");

            var msgBox = new FancyMessageBox(loadedIndicators.ToString(), Language.T("Custom Indicators"))
                             {BoxWidth = 480, BoxHeight = 260, TopMost = true};
            msgBox.Show();
        }
        /// <summary>
        /// Calculates an indicator and returns OK status.
        /// </summary>
        private bool CalculateIndicator(SlotTypes type, Indicator indicator)
        {
            bool okStatus;

            try
            {
                indicator.Calculate(type);

                okStatus = true;
            }
            catch (Exception exception)
            {
                string request = "Please report this error in the support forum!";
                if (indicator.CustomIndicator)
                    request = "Please report this error to the author of the indicator!<br />" +
                              "You may remove this indicator from the Custom Indicators folder.";

                string text =
                    "<h1>Error: " + exception.Message + "</h1>" +
                    "<p>Slot type: <strong>" + type + "</strong><br />" +
                    "Indicator: <strong>" + indicator + "</strong></p>" +
                    "<p>" + request + "</p>";

                const string caption = "Indicator Calculation Error";
                var msgBox = new FancyMessageBox(text, caption) {BoxWidth = 450, BoxHeight = 250};
                msgBox.Show();

                okStatus = false;
            }

            return okStatus;
        }