private void PinConfigChanged() { AxesVM.Update(Config); AxesToButtonsVM.Update(Config); ShiftRegistersVM.Update(Config); ButtonsVM.Update(Config); EncodersVM.Update(Config); LedVM.Update(Config); }
private void ButtonsVM_ConfigChanged() { EncodersVM.Update(Config); }
public MainVM() { // getting current version Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); _config = new DeviceConfig(); _configExchanger = new DeviceConfigExchangerVM(); _configExchanger.Received += ConfigReceived; _configExchanger.Sent += ConfigSent; PinsVM = new PinsVM(Config); PinsVM.ConfigChanged += PinConfigChanged; _joystick = new Joystick(Config); AxesVM = new AxesVM(_joystick, Config); ButtonsVM = new ButtonsVM(_joystick, Config); ButtonsVM.ConfigChanged += ButtonsVM_ConfigChanged; AxesToButtonsVM = new AxesToButtonsVM(_joystick, Config); AxesToButtonsVM.ConfigChanged += AxesToButtonsVM_ConfigChanged; ShiftRegistersVM = new ShiftRegistersVM(Config); ShiftRegistersVM.ConfigChanged += ShiftRegistersVM_ConfigChanged; EncodersVM = new EncodersVM(Config); EncodersVM.ConfigChanged += EncodersVM_ConfigChanged; LedVM = new LedVM(_joystick, Config); LedVM.ConfigChanged += LedVM_ConfigChanged; FirmwareUpdaterVM = new FirmwareUpdaterVM(); GetDeviceConfig = new DelegateCommand(() => { _configExchanger.GetConfigRequest(); WriteLog("Requesting config..", false); }); SendDeviceConfig = new DelegateCommand(() => { _configExchanger.SendConfig(Config); WriteLog("Writting config..", false); }); ResetAllPins = new DelegateCommand(() => PinsVM.ResetPins()); SaveConfig = new DelegateCommand(() => SaveConfigToFile()); LoadConfig = new DelegateCommand(() => ReadConfigFromFile()); SetDefault = new DelegateCommand(() => LoadDefaultConfig()); LoadDefaultConfig(); Hid.Start(Config.Vid); Hid.DeviceAdded += DeviceAddedEventHandler; Hid.DeviceRemoved += DeviceRemovedEventHandler; Hid.DeviceListUpdated += Hid_DeviceListUpdated; // Try to connect to device if (HidDevices.Count > 0) { SelectedDeviceIndex = 0; } WriteLog("Program started", true); }