MoveCurrentToFirst() public method

public MoveCurrentToFirst ( ) : bool
return bool
 public AnalyzerConfigurationViewModel()
 {
     _issuesAnalyzer = ServiceLocator.Resolve<IssuesAnalyzerService>();
     Analyzers = new ListCollectionView(_issuesAnalyzer.AnalyzerContext.Analyzers);
     Analyzers.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
     Analyzers.MoveCurrentToFirst();
 }
 public ProcessorDetails(string code, params FileDetailViewModel[] fileDetails)
 {
     Code = code;
     FileDetails = new ListCollectionView(fileDetails);
     if(fileDetails.Length>0)
         FileDetails.MoveCurrentToFirst();
 }
Exemplo n.º 3
0
 public ViewModel(string key) {
     NotesList = new ListCollectionView(ImportantTips.Entries.Where(x => !x.IsLimited || AppKeyHolder.IsAllRight).Reverse().ToList());
     if (key != null) {
         NotesList.MoveCurrentTo(ImportantTips.Entries.FirstOrDefault(x => x.Id?.Contains(key) == true));
     } else {
         NotesList.MoveCurrentToFirst();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AutomationViewModel"/> class.
        /// </summary>
        public AutomationViewModel()
        {
            var automationTreeService = ServiceLocator.Resolve<AutomationTreeService>();
            _selectedTreeItemService = ServiceLocator.Resolve<SelectedTreeItemService>();

            Elements = new ListCollectionView(automationTreeService.Elements);
            Elements.CurrentChanged += CurrentElementChanged;
            Elements.MoveCurrentToFirst();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BindingEditorViewModel"/> class.
        /// </summary>
        /// <param name="propertyItem">The property item.</param>
        public BindingEditorViewModel(PropertyItem propertyItem)
        {
            _instance = (DependencyObject)propertyItem.Instance;

            Sources = new ListCollectionView(Enum.GetValues(typeof(BindingSource)));
            Sources.MoveCurrentToFirst();
            Sources.CurrentChanged += (s, e) => OnSourceChanged();

            Modes = new ListCollectionView(Enum.GetValues(typeof(BindingMode)));
            Modes.MoveCurrentToFirst();
            Modes.CurrentChanged += (s, e) => UpdateBinding();

            UpdateSourceTriggers = new ListCollectionView(Enum.GetValues(typeof (UpdateSourceTrigger)));
            UpdateSourceTriggers.MoveCurrentToFirst();
            UpdateSourceTriggers.CurrentChanged += (s, e) => UpdateBinding();

            SourceList = new ListCollectionView(_pathItems);
            BuildSourceTree();

            _dpd = DependencyPropertyDescriptor.FromProperty(propertyItem.Property);

            _binding  = BindingOperations.GetBinding((DependencyObject) propertyItem.Instance, _dpd.DependencyProperty);
            if (_binding == null)
            {
                UpdateBinding();
            }
            else
            {
                if( _binding.Source == null )
                {
                    Sources.MoveCurrentTo(BindingSource.DataContext);
                }
                else if( _binding.RelativeSource != null )
                {
                    if( _binding.RelativeSource.Mode == RelativeSourceMode.PreviousData )
                    {
                        Sources.MoveCurrentTo(BindingSource.PreviousData);
                    }
                    else if( _binding.RelativeSource.Mode == RelativeSourceMode.TemplatedParent)
                    {
                        Sources.MoveCurrentTo(BindingSource.TemplatedParent);
                    }
                    else if( _binding.RelativeSource.Mode == RelativeSourceMode.FindAncestor)
                    {
                        Sources.MoveCurrentTo(BindingSource.FindAncestor);
                    }
                }
                UpdateExpression();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VisualTreeViewModel"/> class.
        /// </summary>
        public VisualTreeViewModel()
        {
            _selectedTreeItemService = ServiceLocator.Resolve<SelectedTreeItemService>();
            _selectedTreeItemService.SelectedTreeItemChanged += OnSelectedTreeItemChanged;

            MouseElementServiceSettings = ServiceLocator.Resolve<MouseElementService>().Settings;

            var visualTreeElementService = ServiceLocator.Resolve<VisualTreeService>();
            visualTreeElementService.ElementsChanged += (s, e) => Elements.Refresh();

            //FocusInfo = ServiceLocator.Resolve<FocusedElementService>().Info;

            Elements = new ListCollectionView(visualTreeElementService.Elements);
            Elements.CurrentChanged += CurrentElementChanged;
            Elements.MoveCurrentToFirst();
        }
Exemplo n.º 7
0
 public ViewModel() {
     NotesList = new ListCollectionView(ReleaseNotes.Entries.Where(x => !x.IsLimited || AppKeyHolder.IsAllRight).ToList()) { CustomSort = this };
     NotesList.MoveCurrentToFirst();
 }
        /// <summary>
        /// Instantiates a new AdvancedTabViewModel.
        /// </summary>
        /// <param name="tree">The (not null) SkillTree instance to operate on.</param>
        public AdvancedTabViewModel(SkillTree tree) : base(tree)
        {
            _attributes = CreatePossibleAttributes().ToList();
            AttributesView = new ListCollectionView(_attributes)
            {
                Filter = item => !_addedAttributes.Contains(item),
                CustomSort = Comparer<string>.Create((s1, s2) =>
                {
                    // Sort by group as in AttrGroupOrder first and then by name.
                    var groupCompare = AttrGroupOrder[AttrToGroupConverter.Convert(s1)].CompareTo(
                        AttrGroupOrder[AttrToGroupConverter.Convert(s2)]);
                    return groupCompare != 0 ? groupCompare : string.CompareOrdinal(s1, s2);
                })
            };
            AttributesView.GroupDescriptions.Add(new PropertyGroupDescription(".", AttrToGroupConverter));
            AttributesView.MoveCurrentToFirst();
            AttributeConstraints = new ObservableCollection<AttributeConstraint>();
            NewAttributeConstraint = new AttributeConstraint(AttributesView.CurrentItem as string);

            PseudoAttributesView = new ListCollectionView(_pseudoAttributes)
            {
                Filter = item => !_addedPseudoAttributes.Contains((PseudoAttribute) item)
            };
            PseudoAttributesView.SortDescriptions.Add(new SortDescription("Group", ListSortDirection.Ascending));
            PseudoAttributesView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            PseudoAttributesView.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            PseudoAttributeConstraints = new ObservableCollection<PseudoAttributeConstraint>();

            ReloadPseudoAttributes();

            DisplayName = L10n.Message("Advanced");
        }
Exemplo n.º 9
0
        private void InitializeBookes()
        {
            _localPath = Directory.GetCurrentDirectory();
            if (string.IsNullOrEmpty(BooksXMLFile) || !File.Exists(BooksXMLFile))
            {
                BooksXMLFile = System.IO.Path.Combine(_localPath, "Resources\\books.xml");
            }
            if (!File.Exists(BooksXMLFile))
            {
                File.Create(BooksXMLFile);
            }
            EmptyImage = System.IO.Path.Combine(_localPath, "Resources\\Empty.png");
            _bookList = new ObservableCollection<Book>();

            using (FileStream stream = File.Open(BooksXMLFile, FileMode.Open))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ObservableCollection<Book>));
                this._bookList = serializer.Deserialize(stream) as ObservableCollection<Book>;
            }
            foreach (Book book in this._bookList)
            {
                if (string.IsNullOrEmpty(book.Image))
                {
                    book.Image = EmptyImage;
                }
                else
                {
                    book.Image = book.Image.Replace("$(Booklist)", _localPath);
                }
            }

            _booksView = new ListCollectionView(_bookList);
            _booksView.MoveCurrentToFirst();
            this._booksView.Refresh();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Instantiates a new AdvancedTabViewModel.
        /// </summary>
        /// <param name="tree">The (not null) SkillTree instance to operate on.</param>
        /// <param name="dialogCoordinator">The <see cref="IDialogCoordinator"/> used to display dialogs.</param>
        /// <param name="dialogContext">The context used for <paramref name="dialogCoordinator"/>.</param>
        /// <param name="runCallback">The action that is called when RunCommand is executed.</param>
        public AdvancedTabViewModel(SkillTree tree, IDialogCoordinator dialogCoordinator, object dialogContext,
            Action<GeneratorTabViewModel> runCallback)
            : base(tree, dialogCoordinator, dialogContext, 3, runCallback)
        {
            AdditionalPoints = new LeafSetting<int>(nameof(AdditionalPoints), 21,
                () => TotalPoints = Tree.Level - 1 + AdditionalPoints.Value);
            TotalPoints = Tree.Level - 1 + AdditionalPoints.Value;
            TreePlusItemsMode = new LeafSetting<bool>(nameof(TreePlusItemsMode), false);
            WeaponClass = new LeafSetting<WeaponClass>(nameof(WeaponClass), Model.PseudoAttributes.WeaponClass.Unarmed,
                () => WeaponClassIsTwoHanded = WeaponClass.Value.IsTwoHanded());
            OffHand = new LeafSetting<OffHand>(nameof(OffHand), Model.PseudoAttributes.OffHand.Shield);
            Tags = new LeafSetting<Tags>(nameof(Tags), Model.PseudoAttributes.Tags.None);

            tree.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(SkillTree.Level))
                {
                    TotalPoints = Tree.Level - 1 + AdditionalPoints.Value;
                }
            };

            _attributes = CreatePossibleAttributes().ToList();
            AttributesView = new ListCollectionView(_attributes)
            {
                Filter = item => !_addedAttributes.Contains(item),
                CustomSort = Comparer<string>.Create((s1, s2) =>
                {
                    // Sort by group as in AttrGroupOrder first and then by name.
                    var groupCompare = AttrGroupOrder[AttrToGroupConverter.Convert(s1)].CompareTo(
                        AttrGroupOrder[AttrToGroupConverter.Convert(s2)]);
                    return groupCompare != 0 ? groupCompare : string.CompareOrdinal(s1, s2);
                })
            };
            AttributesView.GroupDescriptions.Add(new PropertyGroupDescription(".", AttrToGroupConverter));
            AttributesView.MoveCurrentToFirst();
            AttributeConstraints = new ObservableCollection<AttributeConstraint>();
            NewAttributeConstraint = new AttributeConstraint(AttributesView.CurrentItem as string);

            PseudoAttributesView = new ListCollectionView(_pseudoAttributes)
            {
                Filter = item => !_addedPseudoAttributes.Contains((PseudoAttribute) item)
            };
            PseudoAttributesView.SortDescriptions.Add(new SortDescription("Group", ListSortDirection.Ascending));
            PseudoAttributesView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            PseudoAttributesView.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            PseudoAttributeConstraints = new ObservableCollection<PseudoAttributeConstraint>();

            ReloadPseudoAttributes();

            DisplayName = L10n.Message("Advanced");

            SubSettings = new ISetting[]
            {
                AdditionalPoints, Iterations, IncludeChecked, ExcludeCrossed,
                TreePlusItemsMode, WeaponClass, OffHand, Tags,
                new ConstraintsSetting(this)
            };
        }
        public MediaFileStateCollectionView(MediaFileState mediaState = null) :
            base(mediaState)
        {           
            Filter = filterFunc;
            InfoIconsCache = InfoIconsCacheStatic;

            MediaFilter = MediaFilterMode.None;           

            SortFunc = MediaFileSortFunctions.getSortFunction(MediaFileSortMode.Name);
            SortMode = MediaFileSortMode.Name;
            
            FilterModes = new ListCollectionView(Enum.GetValues(typeof(MediaFilterMode)));

            SortItemCollection<MediaFileSortItem, MediaFileSortMode> mediaFileSortItemCollection = new SortItemCollection<MediaFileSortItem,MediaFileSortMode>();
            mediaFileSortItemCollection.ItemSortDirectionChanged += mediaFileSortItemCollection_ItemSortDirectionChanged;

            foreach(MediaFileSortMode mode in Enum.GetValues(typeof(MediaFileSortMode))) {

                mediaFileSortItemCollection.Add(new MediaFileSortItem(mode));
            }

            SortModes = new ListCollectionView(mediaFileSortItemCollection);
         
            SortModes.CurrentChanged += (s, e) =>
            {
                MediaFileSortItem sortItem = (MediaFileSortItem)SortModes.CurrentItem;

                SortMode = sortItem.SortMode;
                SortDirection = sortItem.SortDirection;

                SortFunc = MediaFileSortFunctions.getSortFunction(SortMode);

                refresh();
            };

            SortModes.Filter = mediaStateSortModeCollectionViewFilter;

            FilterModes.CurrentChanged += (s, e) =>
            {
                MediaFilter = (MediaFilterMode)FilterModes.CurrentItem;
                              
                SortModes.Refresh();

                bool isRefreshed = false;

                switch (MediaFilter)
                {
                    case MediaFilterMode.None:
                        if (!MediaFileSortFunctions.isAllSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Video:
                        if (!MediaFileSortFunctions.isVideoSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Images:
                        if (!MediaFileSortFunctions.isImageSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Audio:
                        if (!MediaFileSortFunctions.isAudioSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    default:
                        break;
                }

                if (!isRefreshed)
                {
                    refresh();
                }
       
            };
                                    
            FilterModes.MoveCurrentTo(MediaFilterMode.None);
            
        }