Exemplo n.º 1
0
        private void _Plugin_KeyValueReceived(object sender, PlugInEventArgs e)
        {
            if (!_Dispatcher.CheckAccess())
            {
                //Switch thread to GUI thread and invoke
                _Dispatcher.Invoke(new Action(() => _Plugin_KeyValueReceived(sender, e)));
            }

            _Template.Debug(DebugLevel.High, DebugCategory.Information, "Got plugin event for plugin" + e.Name + " key: " + e.Key + " value: " + e.Value);

            try
            {
                bool value = Convert.ToBoolean(e.Value);
                switch (e.Key)
                {
                case "switch1":
                    if (value)
                    {
                        Switch1.Fill = Brushes.LightGreen;
                    }
                    else
                    {
                        Switch1.Fill = Brushes.ForestGreen;
                    }
                    break;

                case "switch2":
                    if (value)
                    {
                        Switch2.Fill = Brushes.LightGreen;
                    }
                    else
                    {
                        Switch2.Fill = Brushes.ForestGreen;
                    }
                    break;

                default:
                    break;
                }
                _Template.SetState("Update", API.State.OK, "");
            }
            catch (Exception ex)
            {
                _Template.SetState("Update", API.State.Error, "Failed to update with data from plugin. " + ex.Message);
            }
        }
Exemplo n.º 2
0
        private void _Plugin_KeyValueReceived(object sender, PlugInEventArgs e)
        {
            if (!_Dispatcher.CheckAccess())
            {
                //Switch thread to GUI thread and invoke
                _Dispatcher.Invoke(new Action(() => _Plugin_KeyValueReceived(sender, e)));
            }

            _Template.Debug(DebugLevel.High, DebugCategory.Information, "Got plugin event for plugin" + e.Name + " key: " + e.Key + " value: " + e.Value);

            try
            {
                bool value = Convert.ToBoolean(e.Value);
                switch (e.Key)
                {
                    case "switch1":
                        if (value)
                        {
                            Switch1.Fill = Brushes.LightGreen;
                        }
                        else
                        {
                            Switch1.Fill = Brushes.ForestGreen;
                        }
                        break;
                    case "switch2":
                        if (value)
                        {
                            Switch2.Fill = Brushes.LightGreen;
                        }
                        else
                        {
                            Switch2.Fill = Brushes.ForestGreen;
                        }
                        break;
                    default:
                        break;
                }
                _Template.SetState("Update", API.State.OK, "");
            }
            catch (Exception ex)
            {
                _Template.SetState("Update", API.State.Error, "Failed to update with data from plugin. " + ex.Message);
            }
        }