예제 #1
0
        public KeySender(PaneHotKeys KeyItems)
        {
            // Store the hotkeys.
            HotKeys    = KeyItems;
            KeyStrings = new List <string>();

            // Name of OBS Window.
            ProcName       = ConfigurationManager.AppSettings.Get("OBSWindowName");
            ServiceAppType = ConfigurationManager.AppSettings.Get("StreamServiceSW");

            // Find the refocus value.
            bool.TryParse(ConfigurationManager.AppSettings.Get("ForceRefocus").ToLower(), out ForceFocusOBS);

            // Check for null.
            if (string.IsNullOrEmpty(ServiceAppType))
            {
                throw new Exception("PLEASE SPECIFY SERVICE APP TYPE (OBS, XPLIT, ETC)");
            }
            if (string.IsNullOrEmpty(ProcName))
            {
                throw new Exception("PLEASE SPECIFY THE OBS WINDOW NAME AND RESTART THIS APP");
            }

            // Pull in the SendAttempts and SendDelayTime
            if (!int.TryParse(ConfigurationManager.AppSettings.Get("KeySendCount"), out SendAttempts))
            {
                SendAttempts = 2;   // Default send count.
            }
            if (!int.TryParse(ConfigurationManager.AppSettings.Get("SendDelayValue"), out SendDelayTime))
            {
                SendDelayTime = 50; // Default delay time.
            }
            // Make sure we don't have some absurd value here.
            uint CheckNegativeSendAttempts  = (uint)SendAttempts;
            uint CheckNegativeSendDelayTime = (uint)SendDelayTime;

            // Negative value check.
            SendAttempts  = (int)CheckNegativeSendAttempts;
            SendDelayTime = (int)CheckNegativeSendDelayTime;

            // Gigantic number check
            if (SendAttempts >= 5)
            {
                SendAttempts = 5;
            }
            if (SendDelayTime >= 500)
            {
                SendAttempts = 500;
            }

            // Convert the list of ConsoleKey items into string items.
            foreach (var KeyItem in HotKeys.HotKeysList)
            {
                KeyStrings.Add(KeyItem.ToString());
            }
        }
예제 #2
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();
            }
        }