private void OnInstall(object sender, EventArgs e) { foreach (var element in m_metaTraders.CheckedItems) { MetaTrader4 trader = (MetaTrader4)element; Install(trader); } }
public MainForm() { InitializeComponent(); try { MetaTrader4[] instances = MetaTrader4.GetAllInstances(); foreach (var element in instances) { m_metaTraders.Items.Add(element); } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private static MetaTrader4 TryToCreate(string root) { try { string directoryName = Path.GetFileName(root); Match match = m_pattern.Match(directoryName); if (!match.Success) { return(null); } string indicatorsPath = Path.Combine(root, cIndicatorsRelativePath); if (!Directory.Exists(indicatorsPath)) { return(null); } string librariesPath = Path.Combine(root, cLibrariesRelativePath); if (!Directory.Exists(librariesPath)) { return(null); } string originPath = Path.Combine(root, cOriginFileName); if (!File.Exists(originPath)) { return(null); } string name; using (StreamReader reader = new StreamReader(originPath)) { name = reader.ReadLine(); } if (string.IsNullOrWhiteSpace(name)) { return(null); } MetaTrader4 result = new MetaTrader4(name, root); return(result); } catch (Exception) { return(null); } }
private void OnExtract(object sender, EventArgs e) { DialogResult result = m_dialog.ShowDialog(); if (DialogResult.OK != result) { return; } try { string root = m_dialog.SelectedPath; MetaTrader4 mt4 = new MetaTrader4(root, root); mt4.TryToInstall(); } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
internal static MetaTrader4[] GetAllInstances() { string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); root = Path.Combine(root, cTerminalRelativePath); string[] directories = Directory.GetDirectories(root); List <MetaTrader4> instances = new List <MetaTrader4>(directories.Length); foreach (var element in directories) { MetaTrader4 instance = TryToCreate(element); if (null != instance) { instances.Add(instance); } } MetaTrader4[] result = instances.ToArray(); return(result); }
private void Install(MetaTrader4 trader) { trader.TryToInstall(); m_metaTraders.Refresh(); }