Example #1
0
        private void DeviceConfigBtn_Click(object sender, RoutedEventArgs e)
        {
            var controlGroup = (DeviceControlGroup)((Button)sender).Tag;
            var deviceType   = controlGroup.DeviceType;
            var selectedItem = (PluginDevice)controlGroup.DeviceComboBox.SelectedItem;

            if (selectedItem?.Factory == null)
            {
                return;
            }
            var parameters = selectedItem.Factory.Parameters;

            if (CollectionUtils.IsNullOrEmpty(parameters))
            {
                return;
            }
            var selectedDevice     = SelectedDevices[deviceType];
            var selectedConsumer   = SelectedConsumers[deviceType];
            var deviceConfigWindow = new DeviceConfigWindow(selectedItem, selectedDevice.Params,
                                                            selectedConsumer.Consumer, selectedConsumer.Params)
            {
                Width = 500
            };

            deviceConfigWindow.ConsumerChanged += (s0, e0) => ConsumerChanged?.Invoke(this, e0);
            if (deviceConfigWindow.ShowDialog(out var deviceParams, out var consumer, out var consumerParams))
            {
                selectedDevice.Params     = deviceParams;
                selectedConsumer.Consumer = consumer;
                selectedConsumer.Params   = consumerParams;
            }
        }
        private void ConsumerComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var streamConsumer = _consumerComboBox.SelectedItem as PluginStreamConsumer;

            var eventArgs = new ConsumerChangedEventArgs(_currentConsumer, streamConsumer, ConsumerConfigurationPanel.Context);

            ConsumerChanged?.Invoke(this, eventArgs);

            InitializeConsumerConfigurationPanel(streamConsumer);
            ConsumerConfigurationPanel.Context = eventArgs.NewConsumerParams ?? EmptyContext.Instance;
        }
        private void ConsumerComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var comboBox    = (ComboBox)sender;
            var viewModel   = (ConsumerConfigViewModel)comboBox.Tag;
            var consumer    = comboBox.SelectedItem as ConsumerTemplate;
            var oldConsumer = viewModel.Current;
            var oldContext  = viewModel.ParamPanel.Context;

            InitializeConsumerConfigurationPanel(viewModel, consumer);

            if (_consumerUpdateLock.IsReferred)
            {
                return;
            }
            var eventArgs = new ConsumerChangedEventArgs(_deviceType, oldConsumer, consumer, oldContext);

            ConsumerChanged?.Invoke(this, eventArgs);
            viewModel.ParamPanel.Context = eventArgs.NewConsumerArgs ?? EmptyContext.Instance;
        }