private void PinConfigChanged() { ButtonsVM.Update(Config); AxesVM.Update(Config); AxesToButtonsVM.Update(Config); ShiftRegistersVM.Update(Config); LedVM.Update(Config); }
private void ConfigReceived(DeviceConfig deviceConfig) { Config = deviceConfig; DeviceFirmwareVersionVM = "Device firmware v" + Config.FirmwareVersion.ToString("X3").Insert(1, ".").Insert(3, ".").Insert(5, "b"); PinsVM.Update(Config); ButtonsVM.Update(Config); AxesVM.Update(Config); AxesToButtonsVM.Update(Config); ShiftRegistersVM.Update(Config); WriteLog("Config received", false); RaisePropertyChanged(nameof(Config)); }
private void ShiftRegistersVM_ConfigChanged() { ButtonsVM.Update(Config); }
private void AxesToButtonsVM_ConfigChanged() { ButtonsVM.Update(Config); AxesVM.Update(Config); }
private void LoadDefaultConfig() { { // TODO: fix serialization var xmlStr = Properties.Resources.default_config; DeviceConfig tmp = Config; tmp = DeSerializeObject <DeviceConfig>(xmlStr, xmlStr.Length); while (tmp.PinConfig.Count > 30) { tmp.PinConfig.RemoveAt(0); } while (tmp.AxisConfig.Count > 8) { tmp.AxisConfig.RemoveAt(0); } for (int i = 0; i < 8; i++) { while (tmp.AxisConfig[i].CurveShape.Count > 11) { tmp.AxisConfig[i].CurveShape.RemoveAt(0); } } while (tmp.ShiftModificatorConfig.Count > 5) { tmp.ShiftModificatorConfig.RemoveAt(0); } while (tmp.ButtonConfig.Count > 128) { tmp.ButtonConfig.RemoveAt(0); } while (tmp.AxisToButtonsConfig.Count > 8) { tmp.AxisToButtonsConfig.RemoveAt(0); } for (int i = 0; i < 8; i++) { while (tmp.AxisToButtonsConfig[i].Points.Count > 13) { tmp.AxisToButtonsConfig[i].Points.RemoveAt(0); } } while (tmp.ShiftRegistersConfig.Count > 4) { tmp.ShiftRegistersConfig.RemoveAt(0); } tmp.DeviceName = tmp.DeviceName.TrimEnd('\0'); Config = tmp; } PinsVM.Config = Config; AxesVM.Config = Config; ButtonsVM.Config = Config; PinsVM.Update(Config); ButtonsVM.Update(Config); AxesVM.Update(Config); AxesToButtonsVM.Update(Config); ShiftRegistersVM.Update(Config); }
private void ReadConfigFromFile() { OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = ".conf"; dlg.Filter = "Config files (*.conf)|*.conf|All files (*.*)|*.*"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { { // TODO: fix serialization DeviceConfig tmp = DeSerializeObject <DeviceConfig>(dlg.FileName); if (tmp != null && (tmp.FirmwareVersion & 0xFFF0) != (Config.FirmwareVersion & 0xFFF0)) { MessageBoxService mbs = new MessageBoxService(); mbs.ShowMessage("Config file is broken or was created in other version of configurator!\r\n" + "Configuration loading will be canceled", "Error"); return; } while (tmp.PinConfig.Count > 30) { tmp.PinConfig.RemoveAt(0); } while (tmp.AxisConfig.Count > 8) { tmp.AxisConfig.RemoveAt(0); } for (int i = 0; i < 8; i++) { while (tmp.AxisConfig[i].CurveShape.Count > 11) { tmp.AxisConfig[i].CurveShape.RemoveAt(0); } } while (tmp.ShiftModificatorConfig.Count > 5) { tmp.ShiftModificatorConfig.RemoveAt(0); } while (tmp.ButtonConfig.Count > 128) { tmp.ButtonConfig.RemoveAt(0); } while (tmp.AxisToButtonsConfig.Count > 8) { tmp.AxisToButtonsConfig.RemoveAt(0); } for (int i = 0; i < 8; i++) { while (tmp.AxisToButtonsConfig[i].Points.Count > 13) { tmp.AxisToButtonsConfig[i].Points.RemoveAt(0); } } while (tmp.ShiftRegistersConfig.Count > 4) { tmp.ShiftRegistersConfig.RemoveAt(0); } tmp.DeviceName = tmp.DeviceName.TrimEnd('\0'); Config = tmp; } PinsVM.Config = Config; AxesVM.Config = Config; ButtonsVM.Config = Config; PinsVM.Update(Config); ButtonsVM.Update(Config); AxesVM.Update(Config); AxesToButtonsVM.Update(Config); ShiftRegistersVM.Update(Config); } }