Example #1
0
        private void LoadLayerShots()
        {
            inGameShotList.Clear();
            outGameShotList.Clear();

            //  Populate Listbox with shots
            int count = _Wirecast.GetShotCount();

            for (int idx = 1; idx <= count; idx++)
            {
                string name        = _Wirecast.GetShotNameWithIndex(idx);
                bool   isInPreview = _Wirecast.IsShotNameInPreview(name);
                bool   isLive      = _Wirecast.IsShotNameLive(name);
                bool   isPlaylist  = _Wirecast.IsPlaylistByShotName(name);

                ShotItem sItem = new ShotItem();
                sItem.name = name;
                sItem.id   = _Wirecast.GetShotIDByName(name);
                sItem.UpdateStatusName(isLive, isInPreview, isPlaylist);
                inGameShotList.Add(sItem);
                outGameShotList.Add(sItem);
            }
        }
Example #2
0
        private void checkSC2State()
        {
            String ip = "localhost";

            if (ipBox.Text != "")
            {
                ip = ipBox.Text;
            }

            String     url     = "http://" + ip + ":6119/ui";
            WebRequest request = WebRequest.Create(url);

            request.Timeout = 1000;

            try
            {
                WebResponse  response           = request.GetResponse();
                Stream       dataStream         = response.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                reader.Close();
                response.Close();

                // this is disgusting but im just prototyping and i kinda dont really
                // need to go through the hassle of working out json parsing libraries
                // #SorryNotSorry
                Boolean tmpInGame = false;
                if (responseFromServer == "{\"activeScreens\":[\"ScreenLoading/ScreenLoading\"]}" || responseFromServer == "{\"activeScreens\":[]}")
                {
                    tmpInGame = true;
                }
                Invoke(new Action(() =>
                {
                    errorLabel.Text = "";
                    textBox1.Text   = responseFromServer;

                    if (inGame && !tmpInGame) // state has changed from in game to out of game
                    {
                        inGame          = false;
                        errorLabel.Text = "out of game";
                        if (isRunning)
                        {
                            ShotItem sItem = (ShotItem)outGameList.SelectedItem;
                            _Wirecast.SetActiveShot(sItem.name);
                            _Wirecast.Go();
                        }
                    }
                    else if (!inGame && tmpInGame) // state has changed from out of game to in game
                    {
                        inGame          = true;
                        errorLabel.Text = "in game";
                        if (isRunning)
                        {
                            ShotItem sItem = (ShotItem)inGameList.SelectedItem;
                            _Wirecast.SetActiveShot(sItem.name);
                            _Wirecast.Go();
                        }
                    }
                }));
            }
            catch (Exception)
            {
                try
                {
                    Invoke(new Action(() =>
                    {
                        errorLabel.Text = "Could not reach SC2";
                    }));
                }
                catch (Exception)
                {
                    // do nothing
                }
            }
        }