public StepI(XElement xml, Song song, int measureOffset) : base(xml, song, measureOffset) { this.mode = int.Parse((string)xml.Attribute("mode")); string img = (string)xml.Attribute("img"); if (img != null) { if (!Global.Instance.BitMapImgs.TryGetValue(Path.GetFileNameWithoutExtension(img), out bmi)) { throw new Exception($"BMI '{img}' not found."); } } var wrk = (string)xml.Attribute("color"); if (wrk != null) { var clrs = new List <SD.Color>(); bool wrap = true; foreach (var clr in wrk.Split(',').Select(clr => clr.Trim())) { if (clr == "wrap") { wrap = true; } else if (clr == "nowrap") { wrap = false; } else { clrs.Add(Clr.FromName(clr)); } } this.palet = new PaletPS(clrs, wrap); } StepTransition trans = null; var nam = (string)xml.Attribute("transition"); if (nam != null) { if (!Global.Instance.StepTransitionDict.TryGetValue(nam, out trans)) { throw new Exception($"Transition '{nam}' not found."); } } else { } if (trans == null) { throw new Exception($"Expecting transition name or transitions element."); } Transition = trans; var regx = (string)xml.Attribute("regex"); if (regx == null) { throw new Exception($"Regex not found."); } regex = new Regex(regx, RegexOptions.IgnoreCase | RegexOptions.Compiled); wrk = (string)xml.Attribute("selector"); if (wrk != null) { selector = SLD.DynamicExpression.CompileLambda <Lit, bool>(wrk); } wrk = (string)xml.Attribute("orderby"); if (wrk != null) { orderby = SLD.DynamicExpression.CompileLambda <Lit, int>(wrk); } wrk = (string)xml.Attribute("groupby"); if (wrk != null) { groupby = SLD.DynamicExpression.CompileLambda <Lit, int>(wrk); } }
static async Task Main(string[] args) { logger.Info("Loading settings..."); var settings = Global.Instance.Settings = AppSettings.LoadAppSettings() ?? new AppSettings(); logger.Info("Loading bitmaps..."); var imgs = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), ".\\..\\..\\BitMapImgs")); foreach (var img in imgs) { using (var bitmap = (SD.Bitmap)SD.Image.FromFile(img)) { Global.Instance.BitMapImgs.Add(Path.GetFileNameWithoutExtension(img), AccessBitmap.ToArray(bitmap)); } } logger.Info($"Bitmaps loaded: {Global.Instance.BitMapImgs.Count()}"); XElement root = null; logger.Info("Loading model..."); root = Global.Instance.Model = XDocument.Load(@".\\..\\..\\Model.xml").Element("root"); Feature.Load(root); Cntrl.Load(root); View.Load(root); Global.Instance.LitArray = Global.Instance.LitDict.Values.OrderBy(lit => lit.GlobalIndex).ToArray(); // Displays var tree = Global.Instance.VuDict["tree"]; Global.Instance.dta = tree.LitArray.Cast <MonoLit>().OrderBy(t => t.Index).ToArray(); Global.Instance.tdOrder = tree.LitArray.Select(n => (short)n.Index).ToArray(); //Global.Instance.dict = Global.Instance.dta.ToDictionary(d => Tuple.Create<int, int>(d.Row, d.Circle), d => d); // Transitions Global.Instance.TreeTransitionDict = new Dictionary <string, TreeTransition>() { { "topdown", TreeTransition.FromEnumerable(Global.Instance.dta.Select(x => (short)x.Row)) } }; foreach (var trans in root.Descendants("transitions").Descendants("transition")) { Global.Instance.TreeTransitionDict.Add((string)trans.Attribute("name"), TreeTransition.FromString((string)trans.Attribute("value"))); } // Font foreach (var felm in root.Descendants("fonts").Descendants("font")) { Global.Instance.FontDict.Add(((string)felm.Attribute("char"))[0], FontUpdate.FromString((string)felm.Attribute("value"))); } // Step Transitions foreach (var tran in root.Descendants("steptransitions").Descendants("transition")) { var name = (string)tran.Attribute("name"); if (string.IsNullOrEmpty(name)) { throw new Exception($"transition must have name."); } Global.Instance.StepTransitionDict.Add(name, StepTransition.Factory(tran.Elements())); } logger.Info("Loading main window..."); //Application.EnableVisualStyles(); //try //{ await StartSTATask(() => { Application.SetCompatibleTextRenderingDefault(false); var frm = new Form2(); Application.Run(frm); }); //} //catch (Exception e) //{ // logger.Info($"Unhandled exception: {e}"); //} }