public void InitializeContext()
 {
     this.item = Mock.Of<IItemContainer>(i =>
         i.Items == Enumerable.Empty<IItemContainer>()
         && i.Icon == System.Drawing.SystemIcons.Application);
     this.filter = Mock.Of<IPickerFilter>(pf =>
         pf.ApplyFilter(this.item) == false
         && pf.MatchesFilter(this.item) == true);
     this.container = new FilteredItemContainer(this.item, this.filter);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FilteredItemContainer"/> class.
        /// </summary>
        /// <param name="parent">The parent item.</param>
        /// <param name="item">The wrapped item.</param>
        /// <param name="filter">The filter to apply to the children of the item.</param>
        private FilteredItemContainer(FilteredItemContainer parent, IItemContainer item, IPickerFilter filter)
        {
            Guard.NotNull(() => item, item);
            Guard.NotNull(() => filter, filter);

            this.filter = filter;
            this.Item = item;
            this.Parent = parent;
            this.Items = item.Items.Where(filter.ApplyFilter).Select(i => new FilteredItemContainer(this, i, filter)).ToArray();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FilteredItemContainer"/> class.
        /// </summary>
        /// <param name="parent">The parent item.</param>
        /// <param name="item">The wrapped item.</param>
        /// <param name="filter">The filter to apply to the children of the item.</param>
        private FilteredItemContainer(FilteredItemContainer parent, IItemContainer item, IPickerFilter filter)
        {
            Guard.NotNull(() => item, item);
            Guard.NotNull(() => filter, filter);

            this.filter = filter;
            this.Item   = item;
            this.Parent = parent;
            this.Items  = item.Items.Where(filter.ApplyFilter).Select(i => new FilteredItemContainer(this, i, filter)).ToArray();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Displays the picker.
        /// </summary>
        public bool ShowDialog()
        {
            if (this.RootItem == null)
            {
                throw new InvalidOperationException(Resources.SolutionSelector_ErrorNoRootItem);
            }

            // Initialize the view
            var selector = new SolutionSelectorView();

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

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

            if (this.ShowAllExpanded)
            {
                root.ExpandAll();
            }
            var model = new SolutionSelectorViewModel(root, this.Filter);

            model.UserMessage       = this.UserMessage;
            model.EmptyItemsMessage = this.EmptyItemsMessage;

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

            // Display the view
            var result = false;

            tracer.ShieldUI(() =>
            {
                result = selector.ShowDialog().GetValueOrDefault();
                if (result)
                {
                    if (model.GetSelectedItems() == null || !model.GetSelectedItems().Any())
                    {
                        result = false;
                    }
                    else
                    {
                        this.SelectedItems = model.GetSelectedItems().Select(i => i.Item);
                    }
                }
            }, Resources.SolutionSelector_ErrorFailedDialog);

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Displays the picker.
        /// </summary>
        public bool ShowDialog()
        {
            if (this.RootItem == null)
            {
                throw new InvalidOperationException(Resources.SolutionSelector_ErrorNoRootItem);
            }

            // Initialize the view
            var selector = new SolutionSelectorView();
            selector.Owner = this.Owner;
            if (!string.IsNullOrEmpty(this.Title))
            {
                selector.Title = this.Title;
            }

            // Initialize the model
            var root = new FilteredItemContainer(this.RootItem, this.Filter);
            if (this.ShowAllExpanded)
            {
                root.ExpandAll();
            }
            var model = new SolutionSelectorViewModel(root, this.Filter);
            model.UserMessage = this.UserMessage;
            model.EmptyItemsMessage = this.EmptyItemsMessage;

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

            // Display the view
            var result = false;
            tracer.ShieldUI(() =>
                {
                    result = selector.ShowDialog().GetValueOrDefault();
                    if (result)
                    {
                        if (model.GetSelectedItems() == null || !model.GetSelectedItems().Any())
                        {
                            result = false;
                        }
                        else
                        {
                            this.SelectedItems = model.GetSelectedItems().Select(i => i.Item);
                        }
                    }

                }, Resources.SolutionSelector_ErrorFailedDialog);

            return result;
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Expands all items in the hierarchy
 /// </summary>
 public static void ExpandAll(this FilteredItemContainer container)
 {
     new[] { container }.ExpandAll();
 }
 public void InitializeContext()
 {
     this.filter = Mock.Of<IPickerFilter>(pf => pf.ApplyFilter(this.solution) == false);
     this.root = new FilteredItemContainer(this.solution, filter);
     this.viewModel = new SolutionPickerViewModel(this.root, filter);
 }
 public void InitializeContext()
 {
     this.childItem = Mock.Of<IItemContainer>();
     this.item = Mock.Of<IItemContainer>(i =>
         i.Items == new[] { this.childItem });
     this.filter = Mock.Of<IPickerFilter>(pf =>
         pf.ApplyFilter(this.childItem) == false
         && pf.MatchesFilter(this.childItem) == false);
     this.container = new FilteredItemContainer(this.item, this.filter);
 }