Ejemplo n.º 1
0
        public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary <string, KeypadButton> buttons)
            : base(key, name)
        {
            _Touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic;
            _Buttons    = buttons;

            _Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange);

            AddPostActivationAction(() =>
            {
                // Link up the button feedbacks to the specified BoolFeedbacks
                foreach (var button in _Buttons)
                {
                    var feedbackConfig = button.Value.Feedback;
                    var device         = DeviceManager.GetDeviceForKey(feedbackConfig.DeviceKey) as Device;
                    if (device != null)
                    {
                        var bKey = button.Key.ToLower();

                        var feedback = device.GetFeedbackProperty(feedbackConfig.FeedbackName);

                        var bFeedback = feedback as BoolFeedback;
                        var iFeedback = feedback as IntFeedback;
                        if (bFeedback != null)
                        {
                            if (bKey == "power")
                            {
                                bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackPower);
                                continue;
                            }
                            else if (bKey == "mute")
                            {
                                bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackMute);
                                continue;
                            }

                            // Link to the Crestron Feedback corresponding to the button number
                            bFeedback.LinkCrestronFeedback(_Touchpanel.Feedbacks[UInt16.Parse(button.Key)]);
                        }
                        else if (iFeedback != null)
                        {
                            if (bKey == "volumefeedback")
                            {
                                var volFeedback = feedback as IntFeedback;
                                // TODO: Figure out how to subsribe to a volume IntFeedback and link it to the voluem
                                volFeedback.LinkInputSig(_Touchpanel.VolumeBargraph);
                            }
                        }
                        else
                        {
                            Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.FeedbackName, device.Key);
                        }
                    }
                    else
                    {
                        Debug.Console(1, this, "Unable to get device with key: {0}", feedbackConfig.DeviceKey);
                    }
                }
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// specifies the touchscreen as a MPC3x30x type
 /// </summary>
 /// <param name="touchscreen"></param>
 public ButtonPanelUtility(MPC3x30xTouchscreen touchscreen)
 {
     this._touchscreen = touchscreen;
 }