public void D3DInit() { RenderTargetProperties renderProp = new RenderTargetProperties() { DpiX = 0, DpiY = 0, MinLevel = FeatureLevel.Level_10, PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied), Type = RenderTargetType.Hardware, Usage = RenderTargetUsage.None }; //set hwnd target properties (permit to attach Direct2D to window) HwndRenderTargetProperties winProp = new HwndRenderTargetProperties() { Hwnd = handle, PixelSize = new Size2(this.ClientSize.Width, this.ClientSize.Height), PresentOptions = PresentOptions.Immediately }; //target creation target = new WindowRenderTarget(Global.Instance.factory2D1, renderProp, winProp); fpsCounter = new SharpFPS(); fpsCounter.Reset(); dsp = new DisplayUpdate(); initialized = true; }
public DisplayUpdate And(DisplayUpdate other) { for (int ndx = 0; ndx < _bits.Length; ndx++) { _bits[ndx] &= other._bits[ndx]; } return(this); }
public static void Runner() { logger.Info("Starting..."); //XElement root; //Global.Instance.Model = root = XDocument.Load(@".\\..\\..\\XMLfile1.xml").Element("root"); //Cntrl.Load(root); //View.Load(root); //// 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.Transitions = new Dictionary<string, DisplayTransition>() //{ {"topdown", DisplayTransition.FromEnumerable(Global.Instance.dta.Select(x => (short)x.Row)) } }; //foreach (XElement trans in root.Descendants("transitions").Descendants("transition")) //{ // Global.Instance.Transitions.Add((string)trans.Attribute("name"), DisplayTransition.FromString((string)trans.Attribute("value"))); //} //// Font //foreach (XElement felm in root.Descendants("fonts").Descendants("font")) //{ // Global.Instance.FontDict.Add(((string)felm.Attribute("char"))[0], FontUpdate.FromString((string)felm.Attribute("value"))); //} Global.Instance.curr = Global.Instance.currDisplay = DisplayUpdate.Get(); Global.Instance.ParseTime = 0; logger.Info("***: " + Global.Instance.ParseTime); Global.Instance.TimeReset(); // Views var pgm = Global.Instance.Model.Descendants("steps").FirstOrDefault(); var stp = new Step(pgm); stp.RunChildren(); }
public async static void Run() { //Global.Instance.doc = XDocument.Load(@".\\..\\..\\XMLfile1.xml"); ////var pgm = doc.Descendants("steps").FirstOrDefault(); ////var stp = new Step(pgm); ////stp.RunChildren(); ////Console.ReadLine(); ////return; //Global.Instance.dta = Global.Instance.doc.Descendants("lites").Descendants("lite").Select(n => new TreeData() //{ // row = (int)n.Attribute("row"), // ctr = (int)n.Attribute("cir"), // col = (int)n.Attribute("col"), // ndx = (int)n.Attribute("ndx"), // color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), (string)n.Attribute("color")), //}).OrderBy(t => t.ndx).ToArray(); ////byte[] mask = new byte[] { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; //Global.Instance.dict = Global.Instance.dta.ToDictionary(d => Tuple.Create<int, int>(d.row, d.ctr), d => d); Global.Instance.curr = DisplayUpdate.Get(); foreach (var td in Global.Instance.dta) { if (td.Row >= 2 && (td.Row == Global.Instance.dta.Max(x => x.Row) || td.Circle == Global.Instance.dta.Where(x => x.Row == td.Row).Max(x => x.Circle) || td.Circle == Global.Instance.dta.Where(x => x.Row == td.Row).Min(x => x.Circle))) { Global.Instance.curr.Set(td); } } var prv = Global.Instance.curr; //Global.Instance.curr.ToConsole(); var pgm = Global.Instance.Model.Descendants("steps").FirstOrDefault(); var stp = new Step(pgm); stp.RunChildren(); Console.ReadLine(); Console.ReadLine(); CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken tkn = cts.Token; var rdr = Task.Factory.StartNew(() => ConRead(tkn), tkn); //var nu = dta.Select(d => d.color == ConsoleColor.Red || d.color == ConsoleColor.Yellow).ToArray(); //var nu = Global.Instance.dta.Select(d => d.row + Math.Abs(d.ctr) < 32).ToArray(); //TreeData td; //for (int x = 2; x <= 34; x += 2) //{ // // var nxt = dta.Select(i => i.row < x ? nu[i.ndx] : prv[i.ndx]).ToArray(); // var nxt = Global.Instance.dta // .Select(d => new { i = d, x = Global.Instance.dict.TryGetValue(Tuple.Create(d.row + 32 - x, d.ctr), out td), t = td }) // .Select(i => i.i.row < x ? (i.t != null ? nu[i.t.ndx] : false) : prv[i.i.ndx]) // .ToArray(); // DisplayIt(nxt); // Thread.Sleep(400); // string cmd; // if (conStrm.TryDequeue(out cmd)) // { // lock (conLock) // { // if (cmd == null) // { // } // else // { // Console.ForegroundColor = ConsoleColor.White; // Console.WriteLine("You pressed '{0}'.", cmd); // if (cmd == "x" || cmd == "X") break; // sendNextMessage(); // } // } // } //} cts.Cancel(); //await rdr; }
private object evalVal() { if (tkntyp == TknTyp.Int) { int x; if (!Int32.TryParse(tknval, out x)) { throw new ArgumentException("Expecting integer:"); } getNext(); return(x); } if (tkntyp == TknTyp.Hex) { int x; if (!Int32.TryParse(tknval.Substring(2, tknval.Length - 2), System.Globalization.NumberStyles.AllowHexSpecifier, null, out x)) { throw new ArgumentException("Expecting integer:"); } getNext(); return(x); } if (tkntyp == TknTyp.Str) { getNext(); return(tknval); } if (tkntyp == TknTyp.Var) { var vari = varistack.FirstOrDefault(v => v.VarName == tknval); if (vari != null) { getNext(); return(vari.BoxedValue); } if (tknval == "curr") { getNext(); return(Global.Instance.curr.Clone()); } var hex = Global.Instance.Model.Descendants("displays").Descendants("display") .First(d => d.Attribute("name").Value == tknval).Attribute("value").Value; if (hex != null) { var disp = DisplayUpdate.Get().FromHex(hex); getNext(); return(disp); } throw new ArgumentException("Variable is not known:" + tknval); } if (tknval == "(") { getNext(); var oprnd = evalOr(); if (tknval != ")") { throw new ArgumentException("Invalid expression:"); } getNext(); return(oprnd); } else { throw new ArgumentException("Expecting operand:"); } }