/// <summary> /// Will Reload all AddIns !AND the settings! /// Has to be callen at least once during startup /// </summary> /// <param name="progress">progress "report" function</param> public void ReloadAddIns(IProgress <Tuple <double, string> > progress) { this.MainFile = new SQF.ClassParser.ConfigField(); this.MainFile.ToClass(); this.ConfigNameFileDictionary = new Dictionary <string, AddInUtil.UIElement>(); string basePath = System.AppDomain.CurrentDomain.BaseDirectory; if (Directory.Exists(basePath + @"AddIns\")) { var dirs = Directory.EnumerateDirectories(basePath + @"AddIns\"); List <string> AddInInfoPaths = new List <string>(); for (int i = 0; i < dirs.Count(); i++) { progress.Report(new Tuple <double, string>((double)i / dirs.Count(), "Checking AddIn Directory")); var it = dirs.ElementAt(i); string curPath = it + @"\info.xml"; if (File.Exists(curPath)) { AddInInfoPaths.Add(curPath); } } for (int i = 0; i < AddInInfoPaths.Count(); i++) { progress.Report(new Tuple <double, string>((double)i / AddInInfoPaths.Count(), "Reading in AddIns")); var it = AddInInfoPaths.ElementAt(i); this.AddIns.Add(AddIn.LoadAddIn(it)); } for (int i = 0; i < this.AddIns.Count(); i++) { var it = this.AddIns.ElementAt(i); it.Initialize(new Progress <double>((d) => { progress.Report(new Tuple <double, string>((i - 1 + d) / AddInInfoPaths.Count(), string.Format("Initializing AddIn '{0}'", it.Info.Name))); }), this.MainFile); for (int j = 0; j < it.UIElements.Count(); j++) { var file = it.UIElements.ElementAt(j); progress.Report(new Tuple <double, string>((j + 1) / it.UIElements.Count(), string.Format("Linking '{0}'s files", it.Info.Name))); this.ConfigNameFileDictionary.Add(file.ConfigKey, file); } } } Settings.Deserialize(); }
public void Initialize(IProgress <double> progress, SQF.ClassParser.ConfigField MainConfigField) { for (int i = 0; i < UIElements.Count; i++) { var file = UIElements[i]; file.Parent = this; progress.Report(i / (UIElements.Count + this.Styles.Count)); file.Initialize(MainConfigField); } for (int i = 0; i < Styles.Count; i++) { var style = Styles[i]; style.Parent = this; progress.Report(i / (UIElements.Count + this.Styles.Count)); style.Initialize(this.ThisPath); } }
/// <summary> /// Will Reload all AddIns !AND the settings! /// Has to be callen at least once during startup /// </summary> /// <param name="progress">progress "report" function</param> public void ReloadAddIns(IProgress<Tuple<double, string>> progress) { this.MainFile = new SQF.ClassParser.ConfigField(); this.MainFile.ToClass(); this.ConfigNameFileDictionary = new Dictionary<string, AddInUtil.UIElement>(); string basePath = System.AppDomain.CurrentDomain.BaseDirectory; if (Directory.Exists(basePath + @"AddIns\")) { var dirs = Directory.EnumerateDirectories(basePath + @"AddIns\"); List<string> AddInInfoPaths = new List<string>(); for (int i = 0; i < dirs.Count(); i++) { progress.Report(new Tuple<double, string>((double)i / dirs.Count(), "Checking AddIn Directory")); var it = dirs.ElementAt(i); string curPath = it + @"\info.xml"; if (File.Exists(curPath)) { AddInInfoPaths.Add(curPath); } } for (int i = 0; i < AddInInfoPaths.Count(); i++) { progress.Report(new Tuple<double, string>((double)i / AddInInfoPaths.Count(), "Reading in AddIns")); var it = AddInInfoPaths.ElementAt(i); this.AddIns.Add(AddIn.LoadAddIn(it)); } for (int i = 0; i < this.AddIns.Count(); i++) { var it = this.AddIns.ElementAt(i); it.Initialize(new Progress<double>((d) => { progress.Report(new Tuple<double, string>((i - 1 + d) / AddInInfoPaths.Count(), string.Format("Initializing AddIn '{0}'", it.Info.Name))); }), this.MainFile); for (int j = 0; j < it.UIElements.Count(); j++) { var file = it.UIElements.ElementAt(j); progress.Report(new Tuple<double, string>((j + 1) / it.UIElements.Count(), string.Format("Linking '{0}'s files", it.Info.Name))); this.ConfigNameFileDictionary.Add(file.ConfigKey, file); } } } Settings.Deserialize(); }
public void Initialize(SQF.ClassParser.ConfigField MainConfigField) { this.Image = Parent.ThisPath + Image.Replace('/', '\\'); this.__ClassPath = Parent.ThisPath + __ClassPath.Replace('/', '\\'); this.__XamlPath = Parent.ThisPath + __XamlPath.Replace('/', '\\'); using (var stream = System.IO.File.OpenRead(this.__ClassPath)) { var parser = new SQF.ClassParser.Generated.Parser(new SQF.ClassParser.Generated.Scanner(stream)); parser.Patch(MainConfigField, false); this.ConfigKey = MainConfigField[MainConfigField.Count - 1].Name; } foreach (var it in this.__PropertiesPath) { var path = System.IO.Path.Combine(Parent.ThisPath, it.TrimStart(new[] { '\\', '/' })); var groups = Group.Load(path); foreach (var groupA in this.Properties) { foreach (var groupB in groups) { if (groupA.Name.ToUpper() == groupB.Name.ToUpper()) { groups.Remove(groupB); groupA.Items.AddRange(groupB.Items); break; } } } this.Properties.AddRange(groups); } foreach (var it in this.__EventsPath) { var path = System.IO.Path.Combine(Parent.ThisPath, it.TrimStart(new[] { '\\', '/' })); this.Events.AddRange(Event.Load(path)); } }