private void _Run_Click(object sender, RoutedEventArgs e) { var instances = (ObservableCollection <List <BatchInstanceOption> >)_ListView.ItemsSource; AppData.Save(((ServiceDisplayInfo)this.DataContext).Name, instances); this.DialogResult = true; }
protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); // Get an alternate file name string configFileName = EdgeServicesConfiguration.DefaultFileName; if (e.Args.Length > 0 && e.Args[0].StartsWith("/") && e.Args[0].Length > 1) { configFileName = e.Args[0].Substring(1); } #if !DEBUG // change to !DEBUG try { EdgeServicesConfiguration.Load(configFileName); } catch (Exception ex) { MessageBox.Show ( messageBoxText: String.Format("Error loading the configuration file {0}\n\n({1}: {2})", Path.Combine(Directory.GetCurrentDirectory(), configFileName), ex.GetType().Name, ex.Message), caption: "Error", button: MessageBoxButton.OK, icon: MessageBoxImage.Error ); Shutdown(); return; } #else EdgeServicesConfiguration.Load(configFileName, readOnly: false); #endif BindingData.Services = new ObservableCollection <ServiceDisplayInfo>(); foreach (ServiceElement serviceConfig in EdgeServicesConfiguration.Current.Services) { if (serviceConfig.IsPublic) { BindingData.Services.Add(new ServiceDisplayInfo(serviceConfig)); } } BindingData.Accounts = new ObservableCollection <AccountDisplayInfo>(); BindingData.Accounts.Add(BindingData.SelectedAccount); foreach (AccountElement accountConfig in EdgeServicesConfiguration.Current.Accounts) { BindingData.Accounts.Add(new AccountDisplayInfo() { AccountConfig = accountConfig }); } // Remember last selected account string lastUsedAccount = AppData.Load <string>("BindingData.SelectedAccount"); if (lastUsedAccount != null) { int accountID; AccountElement accountConfig; if (Int32.TryParse(lastUsedAccount, out accountID) && (accountConfig = EdgeServicesConfiguration.Current.Accounts.GetAccount(accountID)) != null) { BindingData.SelectedAccount = BindingData.Accounts.First(acc => acc.AccountConfig == accountConfig); } } BindingData.PropertyChanged += new PropertyChangedEventHandler((sender, args) => { if (args.PropertyName == "SelectedAccount") { AppData.Save("BindingData.SelectedAccount", BindingData.SelectedAccount.AccountConfig.ID.ToString()); } }); }