public void App_DrawScreen(PInfo[,] information, int x, int y, IRenderingApplication sender) { if (DrawScreen != null) { DrawScreen(information, x, y, this); } }
public void TranslatePositionOf(IRenderingApplication app, Point p) { if (SplitScreens.ContainsKey(app)) { SplitScreens[app].Dimensions.Offset(p); } }
public void SetPositionOf(IRenderingApplication app, Rectangle rec) { if (SplitScreens.ContainsKey(app)) { SplitScreens[app].Dimensions = rec; } }
public void ChangeLayerOf(IRenderingApplication app, int newLayer) { if (SplitScreens.ContainsKey(app)) { SplitScreens[app].SortingLayer = newLayer; } }
public Rectangle GetPositionOf(IRenderingApplication app) { if (SplitScreens.ContainsKey(app)) { return(SplitScreens[app].Dimensions); } return(new Rectangle()); }
/// <summary> /// add an app to render in this screen /// </summary> /// <param name="childApp">App</param> public void AddApp(IRenderingApplication childApp) { // if we allready have an app in our screen we remove all subscriptions from it // we dont want to draw a screen from an inactive app if (app != null) { app.DrawScreen -= receiveDraw; } app = childApp; // we register ourself as the next layer app.DrawScreen += receiveDraw; }
public static void PlaceImage(IRenderingApplication app, int x, int y, PInfo[,] info) { PInfo[,] flipped = new PInfo[info.GetLength(0), info.GetLength(1)]; for (int ax = 0; ax < info.GetLength(0); ax++) { for (int ay = 0; ay < info.GetLength(1); ay++) { flipped[ax, info.GetLength(1) - ay - 1] = info[ax, ay]; } } app.App_DrawScreen(flipped, x + 2, (height - y - flipped.GetLength(1)) + 2, null); }
public void App_DrawScreen(PInfo[,] information, int x, int y, IRenderingApplication sender) { if (DrawScreen != null) { if (sender == this) { DrawScreen(information, x, y, this); } else { //Console.WriteLine(sender); ScreenInfo info = SplitScreens[sender]; DrawScreen(information, x + info.Dimensions.X, y + info.Dimensions.Y, this); } } }
/// <summary> /// Placing an array into the Screenbuffer at a specific location /// </summary> /// <param name="pxls">2-Dim Array of PixelInfos</param> /// <param name="xPos">x Position of the top left corner</param> /// <param name="yPos">y position of the top left corner</param> public void PlacePixels(PInfo[,] pxls, int xPos, int yPos, IRenderingApplication sender) { // write to log int xlength = pxls.GetLength(0); int ylength = pxls.GetLength(1); int xScreenlength = ScreenBuffer.GetLength(0); int yScreenlength = ScreenBuffer.GetLength(1); for (int x = Math.Max(xPos, 0); x < xPos + xlength; x++) { for (int y = Math.Max(0, yPos); y < yPos + ylength; y++) { if (x < xScreenlength && y < yScreenlength) { ScreenBuffer[x, y].Override(pxls[x - xPos, y - yPos]); } } } }
public static void RePlaceAllTiles(IRenderingApplication app, GMU g) { foreach (var item in garden) { PlaceImage(app, item.position.X, item.position.Y, BasicProvider.getInked(1, 1, item.getInfo())); } PlaceImage(app, (int)mower.posX, (int)mower.posY, BasicProvider.getInked(1, 1, new PInfo('O', ConsoleColor.Black, ConsoleColor.Gray))); List <GrasTile> tiles = new List <GrasTile>(); foreach (var item in garden) { tiles.Add(item); } long maxCount = tiles.Where(y => y.cutAmount == tiles.Max(a => a.cutAmount)).ToList().Count; app.App_DrawScreen(BasicProvider.TextToPInfo("Mostvisited Tile: " + tiles.Max(x => x.cutAmount).ToString() + " -> " + tiles.Where(y => y.cutAmount == tiles.Max(a => a.cutAmount)).ToList().Count, width, 1, new PInfo(' ', ConsoleColor.White, ConsoleColor.Black)), height + 3, 3, null); g.PrintFrame(); }
static void Main(string[] args) { Console.ReadLine(); FastGMU gmu = new FastGMU(102, 62); gmu.PlacePixels(BasicProvider.getInked(102, 62, new PInfo().SetBg(ConsoleColor.DarkGray)), 0, 0, null); gmu.PrintFrame(); gmu.PlacePixels(BasicProvider.getInked(100, 60, new PInfo().SetBg(ConsoleColor.Black).SetFg(ConsoleColor.White).SetC(' ')), 1, 1, null); gmu.PrintFrame(); MultiSplitScreenManager SmallScreen = new MultiSplitScreenManager(gmu.PlacePixels, 102, 62); MultiSplitScreenManager splitScreen = new MultiSplitScreenManager(SmallScreen.App_DrawScreen, 100, 60, new PInfo().SetBg(ConsoleColor.Gray), new PInfo().SetBg(ConsoleColor.White).SetC(' ')); SmallScreen.AddScreen(splitScreen, new System.Drawing.Rectangle(1, 1, 100, 60)); WindowScreenManager Test = new WindowScreenManager(20, 30, splitScreen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Black).SetC(' ')); WindowScreenManager Test2 = new WindowScreenManager(20, 30, splitScreen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Black).SetC(' ')); splitScreen.AddScreen(Test, new System.Drawing.Rectangle(79, 5, 20, 30), 2); splitScreen.AddScreen(Test2, new System.Drawing.Rectangle(69, 8, 20, 30), 1); TextBox tb1 = new TextBox("Name", "Test text for some things", new PInfo().SetFg(ConsoleColor.White), 0, 0, Alignment.TopLeft, 20, 10); TextBox tb2 = new TextBox("try", "Another text", new PInfo().SetFg(ConsoleColor.Red).SetBg(ConsoleColor.DarkGray), 0, 0, Alignment.BottomLeft, 20, 10); List <TextBox> content = new List <TextBox>(); content.Add(tb1); content.Add(tb2); WindowSheet sheet = new WindowSheet("Test", content); Test.LoadSheet(sheet); Test2.LoadSheet(sheet); Test2.GetTextBox("Name").Content = "This is another TestBox. How is this working?"; splitScreen.Render(); gmu.PrintFrame(); Console.ReadKey(true); ConsoleKeyInfo info; int selected = 1; IRenderingApplication app = Test; while ((info = Console.ReadKey(true)).Key != ConsoleKey.Spacebar) { switch (info.Key) { case ConsoleKey.D1: selected = 1; app = Test; splitScreen.ChangeLayerOf(Test2, 1); break; case ConsoleKey.D2: selected = 2; app = Test2; splitScreen.ChangeLayerOf(Test2, 3); break; case ConsoleKey.LeftArrow: splitScreen.TranslatePositionOf(app, new System.Drawing.Point(-1, 0)); break; case ConsoleKey.RightArrow: splitScreen.TranslatePositionOf(app, new System.Drawing.Point(1, 0)); break; case ConsoleKey.DownArrow: splitScreen.TranslatePositionOf(app, new System.Drawing.Point(0, 1)); break; case ConsoleKey.UpArrow: splitScreen.TranslatePositionOf(app, new System.Drawing.Point(0, -1)); break; case ConsoleKey.Enter: string input = Console.ReadLine(); Test2.GetTextBox("Name").Content = input; break; default: break; } splitScreen.Render(); gmu.PrintFrame(); } splitScreen.ChangeLayerOf(Test2, 3); splitScreen.Render(); gmu.PrintFrame(); Console.ReadKey(); splitScreen.ChangeLayerOf(Test2, 1); splitScreen.Render(); gmu.PrintFrame(); Console.ReadKey(); splitScreen.ChangeLayerOf(Test2, 3); splitScreen.Render(); gmu.PrintFrame(); Console.ReadKey(); splitScreen.ChangeLayerOf(Test2, 1); splitScreen.Render(); gmu.PrintFrame(); Console.ReadKey(); }
public static void OnIdleHandle(Camera c, IRenderingApplication screen, GMU gmu) { ConsoleKeyInfo input; double MoveDistance = 0.2; double rotateRad = Vector3.DegToRad(5); if (Keyboard.IsKeyDown(Key.A)) { c.Position = c.Position + ((new Vector3(-c.ViewDirection.Z, 0, c.ViewDirection.X).AsNormalized()) * MoveDistance); } if (Keyboard.IsKeyDown(Key.S)) { c.Position = c.Position + ((new Vector3(c.ViewDirection.X, 0, c.ViewDirection.Z).AsNormalized()) * -MoveDistance); } if (Keyboard.IsKeyDown(Key.D)) { c.Position = c.Position + ((new Vector3(c.ViewDirection.Z, 0, -c.ViewDirection.X).AsNormalized()) * MoveDistance); } if (Keyboard.IsKeyDown(Key.W)) { c.Position = c.Position + ((new Vector3(c.ViewDirection.X, 0, c.ViewDirection.Z).AsNormalized()) * MoveDistance); } if (Keyboard.IsKeyDown(Key.Space)) { c.Position = c.Position + (new Vector3(0, 1, 0) * MoveDistance); } if (Keyboard.IsKeyDown(Key.C)) { c.Position = c.Position + (new Vector3(0, -1, 0) * MoveDistance); } if (Keyboard.IsKeyDown(Key.Left)) { c.ViewDirection = c.ViewDirection.RotateY(-rotateRad); } if (Keyboard.IsKeyDown(Key.Down)) { double currAngle = c.ViewDirection.Angle.Y; double target = currAngle + rotateRad; if (target < Math.PI) { // we can change the angle double realAngle = Math.Abs(target - (Math.PI / 2)); double realHeight = Math.Tan(realAngle); double corrected = realHeight * Math.Sqrt(c.ViewDirection.X * c.ViewDirection.X + c.ViewDirection.Z * c.ViewDirection.Z); c.ViewDirection.Y = corrected; if (target > Math.PI / 2) { // negative c.ViewDirection.Y = c.ViewDirection.Y * -1; } } } if (Keyboard.IsKeyDown(Key.Right)) { c.ViewDirection = c.ViewDirection.RotateY(rotateRad); } if (Keyboard.IsKeyDown(Key.Up)) { double currAngleI = c.ViewDirection.Angle.Y; double targetI = currAngleI - rotateRad; if (targetI < Math.PI) { // we can change the angle double realAngle = Math.Abs(targetI - (Math.PI / 2)); double realHeight = Math.Tan(realAngle); double corrected = realHeight * Math.Sqrt(c.ViewDirection.X * c.ViewDirection.X + c.ViewDirection.Z * c.ViewDirection.Z); c.ViewDirection.Y = corrected; if (targetI > Math.PI / 2) { // negative c.ViewDirection.Y = c.ViewDirection.Y * -1; } } } Debug.WriteLine("before render"); screen.App_DrawScreen(c.RenderImage(), 0, 0, null); Debug.WriteLine("After render"); gmu.PrintFrame(); }
public void App_DrawScreen(PInfo[,] information, int x, int y, IRenderingApplication sender) { DrawScreen?.Invoke(information, x, y, sender); }
void RegisterApp(IRenderingApplication app) { app.DrawScreen += App_DrawScreen; }
public void AddScreen(IRenderingApplication app, Rectangle rec, int layer) { SplitScreens.Add(app, new ScreenInfo(rec, layer, true)); RegisterApp(app); }
public void AddScreen(IRenderingApplication app, Rectangle rec) { SplitScreens.Add(app, new ScreenInfo(rec, highestLayer, true)); highestLayer++; RegisterApp(app); }