コード例 #1
0
        private void SetActiveClicked(object sender, RoutedEventArgs e)
        {
            if (this.disabled)
            {
                return;
            }

            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                var selectedIndex = this.DisplayedProfiles.SelectedIndex;

                if (selectedIndex >= 0)
                {
                    // Can't rely on selected Index to get the item as it doesn't handle headers correctly.
                    ProfileSummary selectedItem = (ProfileSummary)this.DisplayedProfiles.SelectedItem;

                    var selectedProfile = this.SettingsProvider.ActualSettings.ProfilesList.FirstOrDefault(p => p.Name == selectedItem.Name && p.ProjectType == selectedItem.ProjectType);

                    if (!selectedProfile.IsActive)
                    {
                        this.SettingsProvider.ActualSettings.ActiveProfileNames[selectedProfile.ProjectType] = selectedProfile.Name;
                        this.SettingsProvider.Save();
                        this.SettingsProvider.ActualSettings.RefreshProfilesList();

                        this.DisplayedProfiles.SelectedIndex = selectedIndex;
                    }
                }
            }
            catch (Exception exc)
            {
                SharedRapidXamlPackage.Logger?.RecordException(exc);
            }
        }
コード例 #2
0
        private void DeleteClicked(object sender, RoutedEventArgs e)
        {
            if (this.disabled)
            {
                return;
            }

            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (this.DisplayedProfiles.SelectedIndex >= 0)
                {
                    ProfileSummary selectedItem = (ProfileSummary)this.DisplayedProfiles.SelectedItem;

                    var selectedProfile = this.SettingsProvider.ActualSettings.ProfilesList[this.DisplayedProfiles.SelectedIndex];
                    var msgResult       = MessageBox.Show(
                        StringRes.Prompt_ConfirmDeleteProfileMessage.WithParams(selectedItem.Name),
                        StringRes.Prompt_ConfirmDeleteProfileTitle,
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Warning);

                    if (msgResult == MessageBoxResult.Yes)
                    {
                        this.SettingsProvider.ActualSettings.Profiles.RemoveAt(this.DisplayedProfiles.SelectedIndex);

                        if (selectedProfile.Name == this.SettingsProvider.ActualSettings.ActiveProfileNames[selectedProfile.ProjectType])
                        {
                            var firstProfile =
                                this.SettingsProvider.ActualSettings.Profiles
                                .FirstOrDefault(p => p.ProjectTypeDescription == selectedProfile.ProjectType);

                            this.SettingsProvider.ActualSettings.ActiveProfileNames[selectedProfile.ProjectType] =
                                firstProfile?.Name ?? string.Empty;
                        }

                        this.SettingsProvider.Save();
                        this.SettingsProvider.ActualSettings.RefreshProfilesList();
                    }
                }
            }
            catch (Exception exc)
            {
                SharedRapidXamlPackage.Logger?.RecordException(exc);
            }
        }
コード例 #3
0
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            if (this.disabled)
            {
                return;
            }

            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                var            selectedIndex = this.DisplayedProfiles.SelectedIndex;
                ProfileSummary selectedItem  = (ProfileSummary)this.DisplayedProfiles.SelectedItem;

                this.SettingsProvider.ActualSettings.Profiles.Add(Profile.CreateNew(selectedItem.ProjectType.AsProjectTypeEnum()));
                this.SettingsProvider.Save();
                this.SettingsProvider.ActualSettings.RefreshProfilesList();

                this.DisplayedProfiles.SelectedIndex = selectedIndex;
            }
            catch (Exception exc)
            {
                SharedRapidXamlPackage.Logger?.RecordException(exc);
            }
        }