Example #1
0
        private void LoadCustomIndicators()
        {
            if (!Configs.LoadCustomIndicators)
            {
                IndicatorManager.CombineAllIndicators();
                return;
            }

            UpdateStatusLabel("- loading custom indicators...");

            try
            {
                CustomIndicators.LoadCustomIndicators();
            }
            catch (Exception e)
            {
                var    checker = new DotNetVersionChecker();
                bool   isNet35 = checker.IsDonNet35Installed();
                string msg;

                if (isNet35)
                {
                    msg = e.Message;
                    if (e.InnerException != null && e.InnerException.Message != "")
                    {
                        msg += Environment.NewLine + e.InnerException.Message;
                    }
                }
                else
                {
                    msg = "FST cannot compile the custom indicators." + Environment.NewLine +
                          "Please install .NET 3.5 or newer and try again.";
                }

                MessageBox.Show(msg, "Loading Custom Indicators",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            if (Configs.ShowCustomIndicators)
            {
                CustomIndicators.ShowLoadedCustomIndicators();
            }
        }
Example #2
0
        /// <summary>
        ///     Load Source Files
        /// </summary>
        public static void LoadCustomIndicators()
        {
            var compiledDlls     = new List <string>();
            var indicatorManager = new IndicatorCompilationManager();
            var errorReport      = new StringBuilder();

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

            string libSettingsPath = Path.Combine(Data.SystemDir, "Libraries.xml");

            Libraries.LoadSettings(libSettingsPath);

            if (Directory.Exists(Data.SourceFolder))
            {
                string[] pathCsFiles = Directory.GetFiles(Data.SourceFolder, "*.cs");
                if (pathCsFiles.Length != 0)
                {
                    foreach (string sourcePath in pathCsFiles)
                    {
                        string errorMessages;
                        if (Libraries.IsSourceCompiled(sourcePath))
                        {
                            continue;
                        }

                        LibRecord record = indicatorManager.LoadCompileSourceFile(sourcePath, out errorMessages);

                        if (record != null)
                        {
                            Libraries.AddRecord(record);
                            compiledDlls.Add(Path.GetFileNameWithoutExtension(sourcePath));
                        }

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

                        errorReport.AppendLine("<h2>File name: " + Path.GetFileName(sourcePath) + "</h2>");
                        string error = errorMessages.Replace(Environment.NewLine, "</br>");
                        error = error.Replace("\t", "&nbsp; &nbsp; &nbsp;");
                        errorReport.AppendLine("<p>" + error + "</p>");
                    }
                }
            }
            if (Directory.Exists(Data.LibraryDir))
            {
                string[] pathDllFiles = Directory.GetFiles(Data.LibraryDir, "*.dll");
                if (pathDllFiles.Length != 0)
                {
                    foreach (string dllPath in pathDllFiles)
                    {
                        string fileName = Path.GetFileNameWithoutExtension(dllPath);
                        if (compiledDlls.Contains(fileName))
                        {
                            continue;
                        }

                        string errorMessages;

                        indicatorManager.LoadDllIndicator(dllPath, out errorMessages);

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

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

            // Adds the custom indicators
            IndicatorManager.ResetCustomIndicators(indicatorManager.CustomIndicatorsList);
            IndicatorManager.CombineAllIndicators();

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