コード例 #1
0
        private void Edit([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var selectedItem = CheckList.SelectedItem as ListBoxItem;

            if (selectedItem == null)
            {
                return;
            }

            var customValidation = selectedItem.Tag as CustomValidation;

            if (customValidation == null)
            {
                Trace.Expected(typeof(CustomValidation));
                return;
            }

            var d = new EditCustomValidationDialog(customValidation);

            if (AppHost.Shell.ShowDialog(d) != true)
            {
                return;
            }

            CustomValidationManager.Update(customValidation);

            selectedItem.Content = customValidation.Title;

            EnableButtons();
        }
コード例 #2
0
        private void Delete([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var selectedIndex = CheckList.SelectedIndex;
            var selectedItem  = CheckList.SelectedItem as ListBoxItem;

            if (selectedItem == null)
            {
                return;
            }

            var customValidation = selectedItem.Tag as CustomValidation;

            if (customValidation == null)
            {
                Trace.Expected(typeof(CustomValidation));
                return;
            }

            if (AppHost.MessageBox(string.Format(Rocks.Resources.MacroOrganizer_DeleteClick_Are_you_sure_you_want_to_delete__0__, customValidation.Title), Rocks.Resources.Confirmation, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
            {
                return;
            }

            CustomValidationManager.Delete(customValidation);

            CheckList.Items.Remove(selectedItem);
            selectedIndex--;

            if (selectedIndex < 0)
            {
                selectedIndex = 0;
            }

            if (selectedIndex < CheckList.Items.Count)
            {
                CheckList.SelectedIndex = selectedIndex;
            }

            EnableButtons();
        }
コード例 #3
0
        private void Add([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var customValidation = new CustomValidation();

            var d = new EditCustomValidationDialog(customValidation);

            if (AppHost.Shell.ShowDialog(d) != true)
            {
                return;
            }

            CustomValidationManager.Add(customValidation);

            CheckList.SelectedIndex = Refresh(customValidation);

            EnableButtons();
        }