Esempio n. 1
0
        private void DeviceComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var controlGroup = (DeviceControlGroup)((ComboBox)sender).Tag;
            var deviceType   = controlGroup.DeviceType;
            var newDevice    = controlGroup.DeviceComboBox.SelectedItem as PluginDevice;

            controlGroup.ConfigButton.IsEnabled  = (newDevice?.Factory.Parameters?.Count ?? 0) > 0;
            controlGroup.PreviewButton.IsEnabled = newDevice?.Factory != null;
            var selectedDevice = SelectedDevices[deviceType];
            var eventArgs      = new DeviceChangedEventArgs(controlGroup.DeviceType, selectedDevice.Device, newDevice, selectedDevice.Params);

            DeviceChanged?.Invoke(this, eventArgs);
            selectedDevice.Device = newDevice;
            selectedDevice.Params = eventArgs.NewDeviceParams ?? EmptyContext.Instance;
        }
        private void DeviceComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var comboBox   = (ComboBox)sender;
            var viewModel  = (DeviceConfigViewModel)comboBox.Tag;
            var device     = comboBox.SelectedItem as DeviceTemplate;
            var oldDevice  = viewModel.Current;
            var oldContext = viewModel.ParamPanel.Context;

            InitializeDeviceConfigurationPanel(device);

            if (_deviceUpdateLock.IsReferred)
            {
                return;
            }
            var eventArgs = new DeviceChangedEventArgs(_deviceType, oldDevice, device, oldContext);

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