private void TcpClient_DataReceived(object sender, DataReceivedArgs e)
        {
            /*
             * Parse the data sent by the display, check for changes
             * in properties that the IDisplay interfaces uses, and
             * raise events accordingly
             */

            //example response: "MULTI.VIEW:QUAD"
            string[] ResponseValues  = e.DataString.ToUpper().Split(':');
            string   PropThatChanged = ResponseValues[0];
            string   NewValue        = ResponseValues[1];

            if (PropThatChanged.IndexOf("DISPLAY.POWER") >= 0)
            {
                _power = (NewValue.IndexOf("ON") >= 0);
                PowerStateChanged?.Invoke(this, new PowerEventArgs
                {
                    State  = _power,
                    uState = _power ? (ushort)1 : (ushort)0
                });
            }
            else if (PropThatChanged.IndexOf("AUDIO.VOLUME") >= 0)
            {
                int    sentValue        = int.Parse(NewValue);                 //convert string value to int
                double scaledPercentage = (sentValue / 100) * ushort.MaxValue; //scale int to proportion of ushort value (65535)
                _volume = (ushort)Math.Floor(scaledPercentage);                //convert to ushort
                VolumeChanged?.Invoke(this, new VolumeEventArgs()
                {
                    CurrentLevel = _volume
                });
            }
            else if (PropThatChanged.IndexOf("MULTI.VIEW") >= 0)
            {
                _quadDisplay = (NewValue.IndexOf("QUAD") >= 0);
                QuadViewChanged?.Invoke(this, new QuadViewEventArgs()
                {
                    State  = _quadDisplay,
                    uState = _quadDisplay ? (ushort)1 : (ushort)0
                });
            }
            else if (PropThatChanged.IndexOf("SOURCE.SELECT(ZONE.1)") >= 0)
            {
                switch (NewValue)
                {
                case ("OPS"):       { _input = eDisplayInput.OpsSlot; break; }

                case ("HDMI.1"):    { _input = eDisplayInput.Hdmi1; break; }

                case ("HDMI.2"):    { _input = eDisplayInput.Hdmi2; break; }

                case ("HDMI.3"):    { _input = eDisplayInput.Hdmi3; break; }

                case ("HDMI.4"):    { _input = eDisplayInput.Hdmi4; break; }

                case ("DP"):        { _input = eDisplayInput.DisplayPort1; break; }
                }

                InputChanged?.Invoke(this, new InputEventArgs()
                {
                    CurrentInput  = _input,
                    uCurrentInput = (ushort)_input
                });
            }
        }
Beispiel #2
0
 private void Display_QuadViewChanged(object sender, QuadViewEventArgs e)
 {
     QuadViewChanged?.Invoke(sender, e);
 }