public bool Init(DisplayNode service) { if (this.CurrentService == service) { return(true); } this.DataContext = this.CurrentService = service; _optionsHeaders = new List <string>(); ConfigurationElement o; if (!service.Configuration.Extensions.TryGetValue(OptionDefinitionCollection.ExtensionName, out o)) { MessageBox.Show("No <OptionDefinitions> section defined in the service.", "Configuration error", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } var options = o as OptionDefinitionCollection; foreach (OptionDefinition option in options) { if (option.IsPublic) { _optionsHeaders.Add(option.Name); } } var grid = this._ListView.View as GridView; for (int i = 0; i < _optionsHeaders.Count; i++) { string option = _optionsHeaders[i]; DataTemplate cellTemplate = new DataTemplate(); cellTemplate.VisualTree = new FrameworkElementFactory(typeof(Grid)); var textbox = new FrameworkElementFactory(typeof(TextBox)); textbox.SetBinding(TextBox.TextProperty, new Binding(String.Format("[{0}].Value", i))); cellTemplate.VisualTree.AppendChild(textbox); grid.Columns.Add(new GridViewColumn() { Header = option, CellTemplate = cellTemplate, Width = 120 }); } ; this._instances = AppData.Load <ObservableCollection <List <BatchInstanceOption> > >(service.Name); if (this._instances == null) { this._instances = new ObservableCollection <List <BatchInstanceOption> >(); this._instances.Add(NewInstance()); } _ListView.ItemsSource = this._instances; return(true); }
public void Init(ServiceDisplayInfo service) { if (this.CurrentService == service) { return; } this.DataContext = this.CurrentService = service; _optionsHeaders = new List <string>(); var options = service.Configuration.Extensions[OptionDefinitionCollection.ExtensionName] as OptionDefinitionCollection; if (options != null) { foreach (OptionDefinition option in options) { if (option.IsPublic) { _optionsHeaders.Add(option.Name); } } } var grid = this._ListView.View as GridView; for (int i = 0; i < _optionsHeaders.Count; i++) { string option = _optionsHeaders[i]; DataTemplate cellTemplate = new DataTemplate(); cellTemplate.VisualTree = new FrameworkElementFactory(typeof(Grid)); var textbox = new FrameworkElementFactory(typeof(TextBox)); textbox.SetBinding(TextBox.TextProperty, new Binding(String.Format("[{0}].Value", i))); cellTemplate.VisualTree.AppendChild(textbox); grid.Columns.Add(new GridViewColumn() { Header = option, CellTemplate = cellTemplate, Width = 120 }); } ; this._instances = AppData.Load <ObservableCollection <List <BatchInstanceOption> > >(service.Name); if (this._instances == null) { this._instances = new ObservableCollection <List <BatchInstanceOption> >(); this._instances.Add(NewInstance()); } _ListView.ItemsSource = this._instances; }
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()); } }); }