コード例 #1
0
        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 MainWindow()
        {
            InitializeComponent();
            MainWindow.Current = this;

            MainWindow.BindingData.Services = new ObservableCollection <DisplayNode>();

            // Add master collection

            // Add accounts
            var accounts = new DisplayNode("Accounts", status: null);

            foreach (AccountElement accountConfig in EdgeServicesConfiguration.Current.Accounts)
            {
                accounts.Children.Add(new DisplayNode(accountConfig));
            }
            BindingData.Services.Add(accounts);

            this.DataContext = MainWindow.BindingData;

            App.DeliveryServer = new Data.Pipeline.DeliveryDBServer();
            App.DeliveryServer.Start(new ConsoleWriter()
            {
                Textbox = _Console
            });

            // Auto start if there is only a single service
            //if (App.BindingData.Services.Count == 1)
            //App.BindingData.Services[0].Start();
        }
コード例 #3
0
        void Instance_ChildServiceRequested(object sender, ServiceRequestedEventArgs e)
        {
            DisplayNode step = this.Children.Single(item => item.Name == e.ServiceName);

            if (step != null)
            {
                step.Start(e.RequestedService);
            }
            else
            {
                step = new DisplayNode(e.RequestedService.Configuration)
                {
                    Unplanned = true
                };
                step.Start(e.RequestedService);
                this.Children.Add(step);
            }
        }
        private void _Toolbar_Advanced_Click(object sender, RoutedEventArgs e)
        {
            var service = _Tree.SelectedItem as DisplayNode;

            if (service == null)
            {
                return;
            }

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

            var dialog = new BatchDialog();

            if (!dialog.Init(service))
            {
                return;
            }

            var result = dialog.ShowDialog();

            if (result != null && result.Value)
            {
                int startIndex = MainWindow.BindingData.Services.IndexOf(service);
                int count      = 0;
                foreach (Dictionary <string, string> options in dialog.GetInstanceOptions())
                {
                    var dup = new DisplayNode(service.Configuration)
                    {
                        IsDuplicate = true, IsExpanded = service.IsExpanded
                    };
                    MainWindow.BindingData.Services.Insert(startIndex + (++count), dup);
                    dup.Start(options);
                }
            }
        }