public void SwitchProviders(ILaunchSettingsUIProvider oldProvider)
        {
            // Get the old custom control and disconnect from notifications
            if (oldProvider?.CustomUI?.DataContext is INotifyPropertyChanged context)
            {
                context.PropertyChanged -= OnCustomUIStateChanged;

                if (context is INotifyDataErrorInfo notifyDataErrorInfo)
                {
                    notifyDataErrorInfo.ErrorsChanged -= OnCustomUIErrorsChanged;
                }
            }

            // Now hook into the current providers notifications. We do that after having set the profile on the provider
            // so that we don't get notifications while the control is initializing. Note that this is likely the first time the
            // custom control is asked for and we want to call it and have it created prior to setting the active profile
            UserControl customControl = ActiveProvider?.CustomUI;

            if (customControl != null)
            {
                ActiveProvider.ProfileSelected(CurrentLaunchSettings);

                context = customControl.DataContext as INotifyPropertyChanged;
                if (context != null)
                {
                    context.PropertyChanged += OnCustomUIStateChanged;
                }

                if (context is INotifyDataErrorInfo notifyDataErrorInfo)
                {
                    notifyDataErrorInfo.ErrorsChanged += OnCustomUIErrorsChanged;
                }
            }
        }
示例#2
0
        protected virtual void NotifySelectedChanged(IWritableLaunchProfile oldProfile)
        {
            // we need to keep the property page control from setting IsDirty when we are just switching between profiles.
            // we still need to notify the display of the changes though
            PushIgnoreEvents();
            try
            {
                // these have no backing store in the viewmodel, we need to send notifications when we change selected profiles
                // consider a better way of doing this
                OnPropertyChanged(nameof(SelectedDebugProfile));
                OnPropertyChanged(nameof(CommandLineArguments));
                OnPropertyChanged(nameof(ExecutablePath));
                OnPropertyChanged(nameof(LaunchPage));
                OnPropertyChanged(nameof(HasLaunchOption));
                OnPropertyChanged(nameof(NativeCodeDebugging));
                OnPropertyChanged(nameof(WorkingDirectory));

                UpdateLaunchTypes();

                ActiveProvider?.ProfileSelected(CurrentLaunchSettings);

                OnPropertyChanged(nameof(IsProfileSelected));
                OnPropertyChanged(nameof(DeleteProfileEnabled));

                SetEnvironmentGrid(oldProfile);

                UpdateActiveProfile();
            }
            finally
            {
                PopIgnoreEvents();
            }
        }