Esempio n. 1
0
        /// <summary>
        /// Displays the picker.
        /// </summary>
        public bool ShowDialog()
        {
            if (this.RootItem == null)
            {
                throw new InvalidOperationException(Resources.SolutionPicker_ErrorNoRootItem);
            }

            // Initialize the view
            var picker = new SolutionPickerView();

            picker.Owner = this.Owner;
            if (!string.IsNullOrEmpty(this.Title))
            {
                picker.Title = this.Title;
            }

            // Initialize the model
            var root  = new FilteredItemContainer(this.RootItem, this.Filter);
            var model = new SolutionPickerViewModel(root, this.Filter);

            model.EmptyItemsMessage = this.EmptyItemsMessage;
            model.SetSelectedItem(this.SelectedItem);

            //Bind the model and view
            picker.DataContext = model;

            var result = false;

            tracer.ShieldUI(() =>
            {
                // Display the view
                result = picker.ShowDialog().GetValueOrDefault();
                if (result)
                {
                    if (model.GetSelectedItem() == null)
                    {
                        result = false;
                    }
                    else
                    {
                        this.SelectedItem = model.GetSelectedItem().Item;
                    }
                }
            }, Resources.SolutionPicker_ErrorFailedDialog);

            return(result);
        }
 public void InitializeContext()
 {
     this.filter    = Mock.Of <IPickerFilter>(pf => pf.ApplyFilter(this.solution) == true);
     this.root      = new FilteredItemContainer(this.solution, filter);
     this.viewModel = new SolutionPickerViewModel(this.root, filter);
 }