public static Load ( string filename ) : bool | ||
filename | string | |
Résultat | bool |
/// <summary> /// Reads the strategy from a file. /// </summary> /// <returns>0 - success.</returns> int OpenStrategy(string strategyFilePath) { try { if (File.Exists(strategyFilePath) && Strategy.Load(strategyFilePath)) { // Successfully opening Data.Strategy.StrategyName = Path.GetFileNameWithoutExtension(strategyFilePath); Data.StrategyDir = Path.GetDirectoryName(strategyFilePath); Data.StrategyName = Path.GetFileName(strategyFilePath); if (Data.Strategy.OpenFilters > Configs.MAX_ENTRY_FILTERS) { Configs.MAX_ENTRY_FILTERS = Data.Strategy.OpenFilters; } if (Data.Strategy.CloseFilters > Configs.MAX_EXIT_FILTERS) { Configs.MAX_EXIT_FILTERS = Data.Strategy.CloseFilters; } } else { Strategy.GenerateNew(); string sMessageText = Language.T("The strategy could not be loaded correctly!"); MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Data.LoadedSavedStrategy = ""; this.Text = Data.ProgramName; } Data.SetStrategyIndicators(); RebuildStrategyLayout(); this.Text = Data.Strategy.StrategyName + " - " + Data.ProgramName; Data.IsStrategyChanged = false; Data.LoadedSavedStrategy = Data.StrategyPath; Data.StackStrategy.Clear(); } catch { Strategy.GenerateNew(); string sMessageText = Language.T("The strategy could not be loaded correctly!"); MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Data.LoadedSavedStrategy = ""; this.Text = Data.ProgramName; RebuildStrategyLayout(); return(1); } return(0); }