/// <summary> /// Shows the loaded custom indicators. /// </summary> static void ShowLoadedCustomIndicators() { if (_indicatorManager.CustomIndicatorsList.Count == 0) { return; } StringBuilder loadedIndicators = new StringBuilder(); loadedIndicators.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>"); loadedIndicators.AppendLine("<p>"); foreach (Indicator indicator in _indicatorManager.CustomIndicatorsList) { loadedIndicators.AppendLine(indicator.ToString() + "</br>"); } loadedIndicators.AppendLine("</p>"); Fancy_Message_Box msgBox = new Fancy_Message_Box(loadedIndicators.ToString(), Language.T("Custom Indicators")); msgBox.BoxWidth = 480; msgBox.BoxHeight = 260; msgBox.TopMost = true; msgBox.Show(); return; }
/// <summary> /// Test is finished /// </summary> static void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { CustomIndicatorsTestResult result = (CustomIndicatorsTestResult)e.Result; if (result.IsErrors) { Fancy_Message_Box msgBoxError = new Fancy_Message_Box(result.ErrorReport, Language.T("Custom Indicators")); msgBoxError.BoxWidth = 550; msgBoxError.BoxHeight = 340; msgBoxError.TopMost = true; msgBoxError.Show(); } Fancy_Message_Box msgBoxOK = new Fancy_Message_Box(result.OKReport, Language.T("Custom Indicators")); msgBoxOK.BoxWidth = 350; msgBoxOK.BoxHeight = 280; msgBoxOK.TopMost = true; msgBoxOK.Show(); return; }
/// <summary> /// Calculates an indicator and returns OK status. /// </summary> bool CalculateIndicator(SlotTypes slotType, Indicator indicator) { bool okStatus; try { indicator.Calculate(slotType); okStatus = true; } catch (Exception excaption) { 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: " + excaption.Message + "</h1>" + "<p>Slot type: <strong>" + slotType.ToString() + "</strong><br />" + "Indicator: <strong>" + indicator.ToString() + "</strong></p>" + "<p>" + request + "</p>"; string caption = "Indicator Calculation Error"; Fancy_Message_Box msgBox = new Fancy_Message_Box(text, caption); msgBox.BoxWidth = 450; msgBox.BoxHeight = 250; msgBox.Show(); okStatus = false; } return(okStatus); }
/// <summary> /// Load Source Files /// </summary> public static void LoadCustomIndicators() { _indicatorManager = new Indicator_Compilation_Manager(); if (!Directory.Exists(Data.SourceFolder)) { System.Windows.Forms.MessageBox.Show("Custom indicators folder does not exist!", Language.T("Custom Indicators")); Indicator_Store.ResetCustomIndicators(null); Indicator_Store.CombineAllIndicators(); return; } string[] pathInputFiles = Directory.GetFiles(Data.SourceFolder, "*.cs"); if (pathInputFiles.Length == 0) { System.Windows.Forms.MessageBox.Show("No custom indicator files found out!", Language.T("Custom Indicators")); Indicator_Store.ResetCustomIndicators(null); Indicator_Store.CombineAllIndicators(); return; } StringBuilder 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", " "); errorReport.AppendLine("<p>" + error + "</p>"); } } // Adds the custom indicators Indicator_Store.ResetCustomIndicators(_indicatorManager.CustomIndicatorsList); Indicator_Store.CombineAllIndicators(); if (isError) { Fancy_Message_Box msgBox = new Fancy_Message_Box(errorReport.ToString(), Language.T("Custom Indicators")); msgBox.BoxWidth = 550; msgBox.BoxHeight = 340; msgBox.TopMost = true; msgBox.Show(); } if (Configs.ShowCustomIndicators) { ShowLoadedCustomIndicators(); } return; }
/// <summary> /// Load Source Files /// </summary> public static void LoadCustomIndicators() { _indicatorManager = new Indicator_Compilation_Manager(); if (!Directory.Exists(Data.SourceFolder)) { System.Windows.Forms.MessageBox.Show("Custom indicators folder does not exist!", Language.T("Custom Indicators")); Indicator_Store.ResetCustomIndicators(null); Indicator_Store.CombineAllIndicators(); return; } string[] pathInputFiles = Directory.GetFiles(Data.SourceFolder, "*.cs"); if (pathInputFiles.Length == 0) { Indicator_Store.ResetCustomIndicators(null); Indicator_Store.CombineAllIndicators(); return; } StringBuilder 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", " "); errorReport.AppendLine("<p>" + error + "</p>"); } } // Adds the custom indicators Indicator_Store.ResetCustomIndicators(_indicatorManager.CustomIndicatorsList); Indicator_Store.CombineAllIndicators(); if (isError) { Fancy_Message_Box msgBox = new Fancy_Message_Box(errorReport.ToString(), Language.T("Custom Indicators")); msgBox.BoxWidth = 550; msgBox.BoxHeight = 340; msgBox.TopMost = true; msgBox.Show(); } if (Configs.ShowCustomIndicators) ShowLoadedCustomIndicators(); return; }
/// <summary> /// Test is finished /// </summary> static void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { CustomIndicatorsTestResult result = (CustomIndicatorsTestResult) e.Result; if (result.IsErrors) { Fancy_Message_Box msgBoxError = new Fancy_Message_Box(result.ErrorReport, Language.T("Custom Indicators")); msgBoxError.BoxWidth = 550; msgBoxError.BoxHeight = 340; msgBoxError.TopMost = true; msgBoxError.Show(); } Fancy_Message_Box msgBoxOK = new Fancy_Message_Box(result.OKReport, Language.T("Custom Indicators")); msgBoxOK.BoxWidth = 350; msgBoxOK.BoxHeight = 280; msgBoxOK.TopMost = true; msgBoxOK.Show(); return; }
/// <summary> /// Shows the loaded custom indicators. /// </summary> static void ShowLoadedCustomIndicators() { if (_indicatorManager.CustomIndicatorsList.Count == 0) return; StringBuilder loadedIndicators = new StringBuilder(); loadedIndicators.AppendLine("<h1>" + Language.T("Custom Indicators") + "</h1>"); loadedIndicators.AppendLine("<p>"); foreach (Indicator indicator in _indicatorManager.CustomIndicatorsList) loadedIndicators.AppendLine(indicator.ToString() + "</br>"); loadedIndicators.AppendLine("</p>"); Fancy_Message_Box msgBox = new Fancy_Message_Box(loadedIndicators.ToString(), Language.T("Custom Indicators")); msgBox.BoxWidth = 480; msgBox.BoxHeight = 260; msgBox.TopMost = true; msgBox.Show(); return; }
/// <summary> /// Calculates an indicator and returns OK status. /// </summary> bool CalculateIndicator(SlotTypes slotType, Indicator indicator) { bool okStatus; try { indicator.Calculate(slotType); okStatus = true; } catch (Exception excaption) { 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: " + excaption.Message + "</h1>" + "<p>Slot type: <strong>" + slotType.ToString() + "</strong><br />" + "Indicator: <strong>" + indicator.ToString() + "</strong></p>" + "<p>" + request + "</p>"; string caption = "Indicator Calculation Error"; Fancy_Message_Box msgBox = new Fancy_Message_Box(text, caption); msgBox.BoxWidth = 450; msgBox.BoxHeight = 250; msgBox.Show(); okStatus = false; } return okStatus; }