Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Set console size.
            Console.SetWindowSize(60, 60);

            // Setup Pane Sizes and Hotkeys here.
            PaneSizes      = new PaneSizeValues();
            HotKeys        = new PaneHotKeys(PaneSizes);
            Sender         = new KeySender(HotKeys);
            ConsoleResizer = new ConsoleResizeChecker(PaneSizes, Sender);

            // Get DelayTime
            if (!int.TryParse(ConfigurationManager.AppSettings.Get("DelayTime"), out DelayTime))
            {
                DelayTime = 1000;
            }

            // Run switcher here.
            while (true)
            {
                RunSwitcher();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write out the current config for the application.
        /// </summary>
        /// <param name="PaneSize">Sizes object</param>
        /// <param name="Sender">Key sender</param>
        public static void WriteConfigInfo(PaneSizeValues PaneSize, KeySender Sender)
        {
            // Store a temp file.
            string TempFile = Path.GetTempFileName();

            using (var ConsoleWriter = new StreamWriter(TempFile))
            {
                // Set Console Output here.
                Console.Clear();
                Console.SetOut(ConsoleWriter);

                // Title info here.
                Console.Clear();
                Console.WriteLine("+---------------------------------------------+");
                Console.WriteLine("|                                             |");
                Console.WriteLine("|          OBS Switcher Version 1.4.3         |");
                Console.WriteLine("|~Created And Maintained By Zack Walsh - 2021~|");
                Console.WriteLine("|                                             |");
                Console.WriteLine("|---------------------------------------------|");
                Console.WriteLine("|    =Configuration Info For This Session=    |");
                Console.WriteLine("|---------------------------------------------|");

                // Print out hotkey info.
                Console.WriteLine("| {0,0} {1,33}", "OBS HotKeys", "|");

                int KeyCounter = 0;
                foreach (var HotKeyItem in HotKeys.HotKeysList)
                {
                    // TESTING FORMAT
                    // | \__ Full Output:    CTL + ALT + SHIFT + A   |
                    // | \__ Pane 1 HotKey:  CTL + ALT + SHIFT + B   |

                    // Store name and format key.
                    string KeyName      = "Pane " + KeyCounter + " HotKey";
                    string FormatString = "{0,0} {1,0} {2,0} {3,3}";
                    string ValueString  = Sender.ModStringExpanded + " + " + HotKeyItem;
                    if (KeyCounter == 0)
                    {
                        KeyName      = "Full Output";
                        FormatString = "{0,0} {1,0} {2,23} {3,3}";
                    }

                    // Write out the formatted string.
                    Console.WriteLine(FormatString, "|", $"\\__ {KeyName}: ", ValueString, "|");

                    // Tick key count.
                    KeyCounter++;
                }

                // Print splitter.
                Console.WriteLine("|---------------------------------------------|");

                // Print out pane size info.
                Console.WriteLine("| {0,0} {1,34}", "Pane Sizes", "|");
                int PaneCounter = 0;
                foreach (var PaneSizeItem in PaneSize.PaneSizesList)
                {
                    // TESTING FORMAT
                    // | \__ Pane 1 Size:       Left Edge - 1150px   |
                    // | \__ Pane 2 Size:  1151px - 2230px          |

                    // Store pane name and info.
                    string PaneName     = "Pane " + (PaneCounter + 1) + " Size";
                    string FormatString = "{0,0} {1,0} {2,17} {3,9}";

                    // String format and write out.
                    string FormatPxEdge = PaneSizeItem.Item1 + "px";

                    // Check for 0px callout.
                    if (FormatPxEdge == "0px")
                    {
                        FormatPxEdge = "Left Edge";
                    }
                    if (PaneCounter == 0 || FormatPxEdge.Contains("Edge"))
                    {
                        FormatString = "{0,0} {1,5} {2,20} {3,6}";
                    }

                    // Store value here.
                    string ValueString = $"{FormatPxEdge} - {PaneSizeItem.Item2}px";

                    // Write out the line here.
                    Console.WriteLine(FormatString, "|", $"\\__ {PaneName}: ", ValueString, "|");

                    // Tick Pane count.
                    PaneCounter++;
                }

                // Command info here.
                Console.WriteLine("|---------------------------------------------|");
                Console.WriteLine("|    =OBS Pane Configuration Setup Helpers=   |");
                Console.WriteLine("|---------------------------------------------|");
                Console.WriteLine("|  Press 'P' and a number to toggle a pane's  |");
                Console.WriteLine("|  outline. Press 'P' twice to see all panes. |");
                Console.WriteLine("|  Or press 'P' and a number for a set pane.  |");
                Console.WriteLine("|                                             |");
                Console.WriteLine("|     These rectangles help visualize the     |");
                Console.WriteLine("|   sizes of panes OBS needs to be setup to   |");
                Console.WriteLine("|  switch between based on your cursor spot.  |");
                Console.WriteLine("|                                             |");
                Console.WriteLine("|  Other Pane Commands                        |");
                Console.WriteLine("|  - Press 'P' then 'C' to clear outlines     |");
                Console.WriteLine("|  - Press 'R' twice to reset pane sizes      |");
                Console.WriteLine("|---------------------------------------------|");
                Console.WriteLine("|          =Main Control Information=         |");
                Console.WriteLine("|---------------------------------------------|");
                Console.WriteLine("|      Press ESCAPE at any time to pause      |");
                Console.WriteLine("|          Press ENTER to continue            |");
                Console.WriteLine("+---------------------------------------------+");
            };

            // Write temp file to console here.
            var StandardConsoleOutput = new StreamWriter(Console.OpenStandardOutput());

            StandardConsoleOutput.AutoFlush = true;
            Console.SetOut(StandardConsoleOutput);

            // Store temp file contents and split into list.
            string[] AllFileLines = File.ReadAllLines(TempFile);
            int      EnterCount   = (Console.WindowHeight - AllFileLines.Length) / 2;

            for (int Counter = 0; Counter < EnterCount - 5; Counter++)
            {
                Console.WriteLine();
            }
            foreach (var LineItem in AllFileLines)
            {
                CenterConsolePrint(LineItem);
            }

            // Delete Temp File.
            try { File.Delete(TempFile); }
            catch { }
        }
Exemplo n.º 3
0
 public ConsoleResizeChecker(PaneSizeValues Sizes, KeySender KeySender)
 {
     // Store key and sizes
     SizeValues = Sizes;
     KeySend    = KeySender;
 }