Esempio n. 1
0
        private void _Toolbar_Advanced_Click(object sender, RoutedEventArgs e)
        {
            var service = _Tree.SelectedItem as ServiceDisplayInfo;

            if (service == null)
            {
                return;
            }

            // always use the root service
            service = service.Root;

            var dialog = new BatchDialog();

            dialog.Init(service);
            var result = dialog.ShowDialog();

            if (result != null && result.Value)
            {
                int startIndex = App.BindingData.Services.IndexOf(service);
                int count      = 0;
                foreach (Dictionary <string, string> options in dialog.GetInstanceOptions())
                {
                    var dup = new ServiceDisplayInfo(service.Configuration)
                    {
                        IsDuplicate = true, IsExpanded = service.IsExpanded
                    };
                    App.BindingData.Services.Insert(startIndex + (++count), dup);
                    dup.Start(options);
                }
            }
        }
        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;
        }
Esempio n. 3
0
        void Instance_ChildServiceRequested(object sender, ServiceRequestedEventArgs e)
        {
            ServiceDisplayInfo step = this.Children.Single(item => item.Name == e.ServiceName);

            if (step != null)
            {
                step.Start(e.RequestedService);
            }
            else
            {
                step = new ServiceDisplayInfo(e.RequestedService.Configuration)
                {
                    Unplanned = true
                };
                step.Start(e.RequestedService);
                this.Children.Add(step);
            }
        }