Exemple #1
0
 private Boolean setObjectVisibility(Boolean currentValue, Theme.ButtonActions action)
 {
     if (action == Theme.ButtonActions.hide)
     {
         return(false);
     }
     else if (action == Theme.ButtonActions.show)
     {
         return(true);
     }
     else if (action == Theme.ButtonActions.toggle)
     {
         if (currentValue == true)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
 }
Exemple #2
0
        // trigger handler
        void triggerTimer_Tick(object sender, EventArgs e)
        {
            TriggerTypes trigger;

            while (SharedData.triggers.Count > 0)
            {
                trigger = (TriggerTypes)SharedData.triggers.Pop();
                int triggerId = -1;

                // search matching trigger and pick first
                for (int i = 0; i < SharedData.theme.triggers.Length; i++)
                {
                    if (SharedData.theme.triggers[i].name.ToLower() == trigger.ToString().ToLower())
                    {
                        triggerId = i;
                        break;
                    }
                }

                // if trigger found execute it
                if (triggerId >= 0)
                {
                    for (int i = 0; i < SharedData.theme.triggers[triggerId].actions.Length; i++)
                    {
                        Theme.ButtonActions action = (Theme.ButtonActions)i;
                        if (SharedData.theme.triggers[triggerId].actions[i] != null)
                        {
                            ClickAction(action, SharedData.theme.triggers[triggerId].actions[i]);
                        }
                    }
                }
            }
        }
Exemple #3
0
        private Boolean ClickAction(Theme.ButtonActions action, string[] objects)
        {
            for (int j = 0; j < objects.Length; j++)
            {
                string[] split = objects[j].Split('-');
                switch (action)
                {
                case Theme.ButtonActions.camera:
                    int camera = -1;
                    foreach (CameraInfo.CameraGroup cam in SharedData.Camera.Groups)
                    {
                        if (cam.Name.ToLower() == objects[j].ToLower())
                        {
                            camera = cam.Id;
                        }
                    }
                    if (camera >= 0)
                    {
                        int driver = Controls.padCarNum(SharedData.Sessions.CurrentSession.FollowedDriver.Driver.NumberPlate);
                        irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, driver, camera);
                        if (SharedData.remoteClient != null && SharedData.serverThread.IsAlive)
                        {
                            SharedData.remoteClient.sendMessage("CAMERA;" + camera);
                            SharedData.remoteClient.sendMessage("DRIVER;" + driver);
                        }
                        SharedData.updateControls = true;
                    }
                    break;

                case Theme.ButtonActions.replay:
                    int  replay = -1;
                    bool result = Int32.TryParse(objects[j], out replay);
                    if (result)
                    {
                        if (replay == 0)     // live
                        {
                            Thread.Sleep(16);
                            irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySearch, (int)iRSDKSharp.ReplaySearchModeTypes.ToEnd, 0);
                            irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 1, 0);
                            SharedData.updateControls = true;
                            SharedData.triggers.Push(TriggerTypes.live);

                            if (SharedData.remoteClient != null)
                            {
                                SharedData.remoteClient.sendMessage("LIVE;");
                            }
                            else if (SharedData.serverThread.IsAlive)
                            {
                                SharedData.serverOutBuffer.Push("LIVE;");
                            }
                        }
                        else     // replay
                        {
                            Thread.Sleep(16);
                            irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlayPosition, (int)iRSDKSharp.ReplayPositionModeTypes.Begin, (int)((Int32)irAPI.sdk.GetData("ReplayFrameNum") - (replay * 60)));
                            irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 1, 0);
                            SharedData.triggers.Push(TriggerTypes.replay);

                            if (SharedData.remoteClient != null)
                            {
                                SharedData.remoteClient.sendMessage("REWIND;" + ((Int32)irAPI.sdk.GetData("ReplayFrameNum") - (replay * 60)).ToString());
                            }
                            else if (SharedData.serverThread.IsAlive)
                            {
                                SharedData.serverOutBuffer.Push("REWIND;" + ((Int32)irAPI.sdk.GetData("ReplayFrameNum") - (replay * 60)).ToString());
                            }
                        }
                    }
                    break;

                case Theme.ButtonActions.playspeed:
                    Int32 playspeed = Int32.Parse(objects[j]);
                    Int32 slowmo    = 0;
                    if (playspeed < 0)
                    {
                        playspeed = Math.Abs(playspeed) - 1;
                        slowmo    = 1;
                    }

                    Thread.Sleep(16);
                    irAPI.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, playspeed, slowmo);
                    break;

                default:
                    switch (split[0])
                    {
                    case "Overlay":         // overlays
                        for (int k = 0; k < SharedData.theme.objects.Length; k++)
                        {
                            if (SharedData.theme.objects[k].name == split[1])
                            {
                                Boolean isStandings = SharedData.theme.objects[k].dataset == Theme.dataset.standing || SharedData.theme.objects[k].dataset == Theme.dataset.points;

                                if (isStandings && action == Theme.ButtonActions.show)
                                {
                                    SharedData.theme.objects[k].page++;
                                }

                                if (SharedData.lastPage[k] == true && isStandings && action == Theme.ButtonActions.show)
                                {
                                    SharedData.theme.objects[k].visible = setObjectVisibility(SharedData.theme.objects[k].visible, Theme.ButtonActions.hide);
                                    SharedData.theme.objects[k].page    = -1;
                                    SharedData.lastPage[k] = false;

                                    return(true);
                                }
                                else
                                {
                                    SharedData.theme.objects[k].visible = setObjectVisibility(SharedData.theme.objects[k].visible, action);
                                    if ((action == Theme.ButtonActions.toggle) && (SharedData.theme.objects[k].visible == false))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                        break;

                    case "Image":         // images
                        for (int k = 0; k < SharedData.theme.images.Length; k++)
                        {
                            if (SharedData.theme.images[k].name == split[1])
                            {
                                SharedData.theme.images[k].visible = setObjectVisibility(SharedData.theme.images[k].visible, action);
                            }
                        }
                        break;

                    case "Ticker":         // tickers
                        for (int k = 0; k < SharedData.theme.tickers.Length; k++)
                        {
                            if (SharedData.theme.tickers[k].name == split[1])
                            {
                                SharedData.theme.tickers[k].visible = setObjectVisibility(SharedData.theme.tickers[k].visible, action);
                            }
                        }
                        break;

                    case "Video":         // video
                        for (int k = 0; k < SharedData.theme.videos.Length; k++)
                        {
                            if (SharedData.theme.videos[k].name == split[1])
                            {
                                SharedData.theme.videos[k].visible = setObjectVisibility(SharedData.theme.videos[k].visible, action);
                            }
                        }
                        break;

                    case "Sound":         // sound
                        for (int k = 0; k < SharedData.theme.sounds.Length; k++)
                        {
                            if (SharedData.theme.sounds[k].name == split[1])
                            {
                                switch (action)
                                {
                                case Theme.ButtonActions.hide:
                                    SharedData.theme.sounds[k].playing = false;
                                    break;

                                default:
                                    SharedData.theme.sounds[k].playing = true;
                                    break;
                                }
                            }
                        }
                        break;

                    case "Trigger":         // triggers
                        switch (split[1])
                        {
                        case "flags":
                            if (SharedData.Sessions.CurrentSession.Flag == Sessions.SessionInfo.sessionFlag.white)
                            {
                                SharedData.triggers.Push(TriggerTypes.flagWhite);
                            }
                            else if (SharedData.Sessions.CurrentSession.Flag == Sessions.SessionInfo.sessionFlag.checkered)
                            {
                                SharedData.triggers.Push(TriggerTypes.flagCheckered);
                            }
                            else if (SharedData.Sessions.CurrentSession.Flag == Sessions.SessionInfo.sessionFlag.yellow)
                            {
                                SharedData.triggers.Push(TriggerTypes.flagYellow);
                            }
                            else
                            {
                                SharedData.triggers.Push(TriggerTypes.flagGreen);
                            }
                            break;

                        case "lights":
                            if (SharedData.Sessions.CurrentSession.StartLight == Sessions.SessionInfo.sessionStartLight.ready)
                            {
                                SharedData.triggers.Push(TriggerTypes.lightsReady);
                            }
                            else if (SharedData.Sessions.CurrentSession.StartLight == Sessions.SessionInfo.sessionStartLight.set)
                            {
                                SharedData.triggers.Push(TriggerTypes.lightsSet);
                            }
                            else if (SharedData.Sessions.CurrentSession.StartLight == Sessions.SessionInfo.sessionStartLight.go)
                            {
                                SharedData.triggers.Push(TriggerTypes.lightsGo);
                            }
                            else
                            {
                                SharedData.triggers.Push(TriggerTypes.lightsOff);
                            }
                            break;

                        default:
                            break;
                        }
                        break;

                    case "Click":
                    {
                        for (int i = 0; i < SharedData.theme.buttons.Length; i++)
                        {
                            if (SharedData.theme.buttons[i].name == split[1])
                            {
                                Button dummyButton = new Button();
                                dummyButton.Name    = "customButton" + i.ToString();
                                dummyButton.Content = "";
                                this.HandleClick(dummyButton, new RoutedEventArgs());
                                break;
                            }
                        }
                        break;
                    }

                    default:         // script or not
                        if (SharedData.scripting.Scripts.Contains(split[0]))
                        {
                            SharedData.scripting.PressButton(split[0], split[1]);
                        }
                        break;
                    }
                    break;
                }
            }
            return(false);
        }
Exemple #4
0
        void HandleClick(object sender, RoutedEventArgs e)
        {
            Button button = new Button();

            try
            {
                button = (Button)sender;
            }
            finally
            {
                int buttonId = Int32.Parse(button.Name.Substring(12));

                if (button.Content != null && button.Content.ToString() != "")
                {
                    if (SharedData.remoteClient != null) // empty button means page switchers dummy button which is ignored
                    {
                        SharedData.remoteClient.sendMessage("BUTTON;" + button.Name);
                    }
                    else if (SharedData.serverThread.IsAlive)
                    {
                        SharedData.serverOutBuffer.Push("BUTTON;" + button.Name);
                    }
                }

                if (SharedData.theme.buttons[buttonId].delay > 0)
                {
                    if (SharedData.theme.buttons[buttonId].active && button.Content.ToString() != "")
                    {
                        SharedData.theme.buttons[buttonId].active = false;
                    }
                    else
                    {
                        SharedData.theme.buttons[buttonId].pressed = DateTime.Now;
                        SharedData.theme.buttons[buttonId].active  = true;
                    }
                }

                for (int i = 0; i < SharedData.theme.buttons[buttonId].actions.Length; i++)
                {
                    Theme.ButtonActions action = (Theme.ButtonActions)i;
                    if (SharedData.theme.buttons[buttonId].actions[i] != null)
                    {
                        if (ClickAction(action, SharedData.theme.buttons[buttonId].actions[i])) // if last page
                        {
                            if (SharedData.theme.buttons[buttonId].delayLoop)                   // keep pushing
                            {
                                ClickAction(action, SharedData.theme.buttons[buttonId].actions[i]);
                            }
                            else // hide
                            {
                                ClickAction(Theme.ButtonActions.hide, SharedData.theme.buttons[buttonId].actions[i]);
                                SharedData.theme.buttons[buttonId].active = false;
                            }
                        }

                        if (SharedData.theme.buttons[buttonId].delayLoop && !SharedData.theme.buttons[buttonId].active)
                        {
                            ClickAction(Theme.ButtonActions.hide, SharedData.theme.buttons[buttonId].actions[i]);
                        }
                    }
                }
            }
        }