Ejemplo n.º 1
0
        private void ExecuteAddConfigItem(object param)
        {
            if (_isChangingConfig)
            {
                return;
            }
            if (_disposed)
            {
                return;
            }
            _isChangingConfig = true;
            Debug.Assert(param != null && param is IConfigurationLayer);

            IConfigurationLayer           layer = param as IConfigurationLayer;
            CreateConfigurationItemWindow w     = new CreateConfigurationItemWindow(_serviceInfoManager);

            w.Owner = _window;

            var windowResult = w.ShowDialog();

            if (windowResult == true)
            {
                string serviceOrPluginId = w.ViewModel.SelectedServiceOrPluginId;
                if (serviceOrPluginId != null)
                {
                    var itemAddResult = layer.Items.Add(serviceOrPluginId, w.ViewModel.SelectedStatus);
                    if (!itemAddResult.Success)
                    {
                        string message = itemAddResult.Describe();

                        RaiseUserError("Couldn't add item", String.Format("Configuration of {0} could not be added, as it would cause the following error:\n\n{1}",
                                                                          _serviceInfoManager.GetDescriptionOfServiceOrPluginFullName(serviceOrPluginId),
                                                                          message)
                                       );
                    }
                }
            }
            _isChangingConfig = false;
        }
        private void ExecuteAddConfigItem( object param )
        {
            if( _isChangingConfig ) return;
            if( _disposed ) return;
            _isChangingConfig = true;
            Debug.Assert( param != null && param is IConfigurationLayer );

            IConfigurationLayer layer = param as IConfigurationLayer;
            CreateConfigurationItemWindow w = new CreateConfigurationItemWindow( _serviceInfoManager );
            w.Owner = _window;

            var windowResult = w.ShowDialog();

            if( windowResult == true )
            {
                string serviceOrPluginId = w.ViewModel.SelectedServiceOrPluginId;
                if( serviceOrPluginId != null )
                {
                    var itemAddResult = layer.Items.Add( serviceOrPluginId, w.ViewModel.SelectedStatus );
                    if( !itemAddResult.Success )
                    {
                        string message = itemAddResult.Describe();

                        RaiseUserError( "Couldn't add item", String.Format( "Configuration of {0} could not be added, as it would cause the following error:\n\n{1}",
                            _serviceInfoManager.GetDescriptionOfServiceOrPluginFullName( serviceOrPluginId ),
                            message )
                            );
                    }
                }
            }
            _isChangingConfig = false;
        }