public SettingsViewModel() { IntroBoxVisible = Properties.Settings.Default.ShowIntroBox; HideIntroBoxCommand = new DelegateCommand(() => { IntroBoxVisible = false; Properties.Settings.Default.ShowIntroBox = false; Properties.Settings.Default.Save(); }); BrowseForDbLibCommand = new DelegateCommand(BrowseForDbLib); UpdateUdlFileCommand = new DelegateCommand(UpdateUdlFile, () => !String.IsNullOrEmpty(PathToDbLib) && File.Exists(PathToDbLib)); PathToDbLib = Properties.Settings.Default.AltiumDbPath; if (!String.IsNullOrEmpty(PathToDbLib)) { PathToUdl = AltiumFile.ReadUdlLocation(PathToDbLib); } }
void UpdateUdlFile() { ShowUdlSuccessMessage = false; ShowUdlErrorMessage = false; UdlMessage = ""; if (String.IsNullOrEmpty(MainViewModel.LoginRegisterViewModel.Password)) { MainViewModel.LoginRegisterViewModel.UserIsLoggedIn = false; return; } string newUdlPath = Path.ChangeExtension(PathToDbLib, "udl"); var cred = new UdlCredentials { Username = MainViewModel.LoginRegisterViewModel.Username, Password = MainViewModel.LoginRegisterViewModel.Password, Server = "csql.database.windows.net" }; if (AltiumFile.CreateMsSqlUdlFile(newUdlPath, cred)) { if (AltiumFile.SetUdlLocationInDbLib(PathToDbLib, newUdlPath)) { PathToUdl = AltiumFile.ReadUdlLocation(PathToDbLib); ShowUdlSuccessMessage = true; UdlMessage = "Successfully created/updated the UDL file with your Azure credentials, and set the file path in the Altium DbLib."; } else { ShowUdlErrorMessage = true; UdlMessage = "Could not update Altium DbLib file with new UDL file location - check Altium is not open, and you have permission to edit the file!"; } } else { ShowUdlErrorMessage = true; UdlMessage = "Could not create the UDL file on disk - check you have permission to create a file here!"; } }