/// <summary> /// Print out what pane is currently open /// </summary> /// <param name="PaneIndex"></param> private static void PrintCurrentPane(int PaneIndex, MouseCords XAndYPos) { // Style mouse output. StyleSheet RunningOutputStyle = new StyleSheet(Color.White); RunningOutputStyle.AddStyle(@"\[|\]|", Color.DarkGray, match => match.ToString()); RunningOutputStyle.AddStyle(@"X:|Y:", Color.Yellow, match => match.ToString()); RunningOutputStyle.AddStyle(@"ZERO", Color.Orange, match => match.ToString()); RunningOutputStyle.AddStyle(@"MAIN", Color.HotPink, match => match.ToString()); // Write seperator line. for (int Count = 0; Count < Console.WindowWidth; Count++) { Console.WriteStyled("-", RunningOutputStyle); } Console.Write(""); // Check for main here if (XAndYPos == null || PaneIndex == -1) { Console.WriteStyled("[X: MAIN][Y: MAIN] | ", RunningOutputStyle); } else { // Write mouse cords. string xPos = "[X: " + XAndYPos.PosX.ToString("D4") + "]"; string yPos = "[Y: " + XAndYPos.PosY.ToString("D4") + "]"; if (XAndYPos.PosY < 0) { yPos = "[Y: ZERO]"; } Console.WriteStyled(xPos + yPos + " | ", RunningOutputStyle); } // Write pane info. Console.ForegroundColor = Color.DarkGray; Console.Write("["); if (PaneIndex >= 0) { Console.ForegroundColor = PaneSizes.ConsolePaneColors[PaneIndex]; Console.Write($"SWITCHING TO OBS PANE NUMBER {PaneIndex + 1}"); } if (PaneIndex < 0) { Console.ForegroundColor = Color.White; Console.Write("SWITCHING TO OBS MAIN PANE"); } Console.ForegroundColor = Color.DarkGray; Console.WriteLine("]"); // Write seperator line. for (int Count = 0; Count < Console.WindowWidth; Count++) { Console.WriteStyled("-", RunningOutputStyle); } Console.Write(""); }
/// <summary> /// Kicks off the pane switching loop. /// </summary> private static void RunSwitcher() { // Start the console resizer ConsoleResizer.ResizeWanted = true; ConsoleResizer.CheckForResize(); // Write config info. WriteConfigInfo(PaneSizes, Sender); // Wait for user to hit enter to begin. // Check for next input key here. while (true) { // If no new key wait. if (!Console.KeyAvailable) { continue; } var NextKey = Console.ReadKey(true); if (NextKey.Key == ConsoleKey.Enter) { break; } if (NextKey.Key == ConsoleKey.R) { // Check for R again to confirm. var ResetKey = Console.ReadKey(true); if (ResetKey.Key != ConsoleKey.R) { continue; } // Reset the pane keys if wanted. PaneSizes = new PaneSizeValues(true); WriteConfigInfo(PaneSizes, Sender); } if (NextKey.Key == ConsoleKey.P) { // Draw new boxes and update the UI HotKeys.ProcessPaneKey(); PaneSizes = new PaneSizeValues(); WriteConfigInfo(PaneSizes, Sender); } } // Clear the console. Console.Clear(); // Store last move so we dont repeat int LastMoveIndex = -1; // Loop only while we have not key pressed and we can read a key. while (!(Console.KeyAvailable && (Console.ReadKey(true).Key == ConsoleKey.Escape))) { // Wait the delay time and get mouse location Thread.Sleep(DelayTime); var XAndYPos = new MouseCords(); // Check invalid Y pos value. if (XAndYPos.PosY < 0) { // Make sure we wanna do this. if (ConfigurationManager.AppSettings.Get("ForcePositiveY") != "TRUE") { continue; } // Change the view if needed. if (LastMoveIndex != -1) { PrintCurrentPane(-1, null); Sender.SwitchView(-1); } // Move on the loop. continue; } // Find the X Pane item range. if (PaneSizes.PaneSizesList.Count == 0) { throw new Exception("FAILED TO FIND ANY PANE SETTINGS ITEMS WHEN CHANGING VIEWS!"); } for (int PaneIndex = 0; PaneIndex < PaneSizes.PaneSizesList.Count; PaneIndex++) { // Get the top and bottom range items. int MinRange = PaneSizes.PaneSizesList[PaneIndex].Item1; int MaxRange = PaneSizes.PaneSizesList[PaneIndex].Item2; // Check if we're in range and need to move. // RANGE IS SETUP AS MIN AND COUNT. NOT MIN AND MAX!! if (!Enumerable.Range(MinRange, MaxRange - MinRange).Contains(XAndYPos.PosX)) { continue; } if (PaneIndex == LastMoveIndex) { break; } // Store the index of the pane we are on and print that info out. Sender.SwitchView(PaneIndex + 1); PrintCurrentPane(PaneIndex, XAndYPos); LastMoveIndex = PaneIndex; // Move on break; } } // Stop resizer, move back to home and clear out. ConsoleResizer.ResizeWanted = false; Sender.SwitchView(-1); PrintCurrentPane(-1, null); Console.Clear(); }