コード例 #1
0
        public TextKeyViewModel(string textKey, bool isFullKey, TreeViewItemViewModel parent, MainViewModel mainWindowVM)
            : base(parent, false)
        {
            CultureTextVMs = new ObservableCollection<CultureTextViewModel>();
            TextKey = textKey;
            IsFullKey = isFullKey;

            MainWindowVM = mainWindowVM;

            UpdateIcon();
        }
コード例 #2
0
        public TextKeyViewModel(string textKey, bool isFullKey, TreeViewItemViewModel parent, MainViewModel mainWindowVM)
            : base(parent, false)
        {
            CultureTextVMs = new ObservableCollection <CultureTextViewModel>();
            TextKey        = textKey;
            IsFullKey      = isFullKey;

            MainWindowVM = mainWindowVM;

            UpdateIcon();
        }
コード例 #3
0
        protected TreeViewItemViewModel(TreeViewItemViewModel parent, bool lazyLoadChildren)
        {
            IsVisible = true;
            IsEnabled = true;
            Parent = parent;

            Children = new ObservableCollection<TreeViewItemViewModel>();

            VisibleChildren = new ListCollectionView(Children);
            VisibleChildren.Filter = item => (item is TreeViewItemViewModel) && (item as TreeViewItemViewModel).IsVisible;

            if (lazyLoadChildren)
                Children.Add(DummyChild);
        }
コード例 #4
0
        /// <summary>
        /// Returns a value indicating whether the current instance is a parent or grand-parent of
        /// the specified child item.
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        public bool IsAParentOf(TreeViewItemViewModel child)
        {
            TreeViewItemViewModel parent = child;

            do
            {
                parent = parent.Parent;
                if (parent != null && parent == this)
                {
                    return(true);
                }
            }while (parent != null);
            // All parents compared, it's not our (grand-)child
            return(false);
        }
コード例 #5
0
        protected TreeViewItemViewModel(TreeViewItemViewModel parent, bool lazyLoadChildren)
        {
            IsVisible = true;
            IsEnabled = true;
            Parent    = parent;

            Children = new ObservableCollection <TreeViewItemViewModel>();

            VisibleChildren        = new ListCollectionView(Children);
            VisibleChildren.Filter = item => (item is TreeViewItemViewModel) && (item as TreeViewItemViewModel).IsVisible;

            if (lazyLoadChildren)
            {
                Children.Add(DummyChild);
            }
        }
コード例 #6
0
        /// <summary>
        /// Finds the remaining item after some items have been deleted.
        /// </summary>
        /// <param name="predicate">Function that determines whether an item is acceptable.</param>
        /// <returns>The first accepted item, or null.</returns>
        public TreeViewItemViewModel FindRemainingItem(Predicate <TreeViewItemViewModel> predicate)
        {
            // Start on the current tree level
            TreeViewItemViewModel level = this;

            do
            {
                // Try the following siblings
                TreeViewItemViewModel position = level;
                do
                {
                    position = position.FindNextSibling();
                    if (position != null && predicate(position))
                    {
                        return(position);
                    }
                }while (position != null);

                // Try the preceding siblings
                position = this;
                do
                {
                    position = position.FindPreviousSibling();
                    if (position != null && predicate(position))
                    {
                        return(position);
                    }
                }while (position != null);

                // Continue on the parent level (stop on the root item)
                level = level.Parent;
            }while (level != null && level.Parent != null);

            // Nothing remains
            return(null);
        }
コード例 #7
0
 /// <summary>
 /// Refreshes a single item in the CollectionView of all (filtered) visible children.
 /// </summary>
 /// <param name="item">The changed item.</param>
 /// <remarks>
 /// This makes use of the IEditableObject implementation of the item. When an item is
 /// edited through this mechanism, and the update is committed, the CollectionView will
 /// re-evaluate the item and apply the filtering accordingly. This method must be called
 /// for each item that may have been updated. Changes that are signalled through
 /// INotifyPropertyChanged are not considered by a CollectionView. Updating each single
 /// log item avoids the Reset type change notification and the focused item issue.
 /// </remarks>
 private void RefreshVisibleChildrenItem(TreeViewItemViewModel item)
 {
     var ev = VisibleChildren as IEditableCollectionView;
     if (ev != null)
     {
         ev.EditItem(item);
         ev.CommitEdit();
     }
 }
コード例 #8
0
 /// <summary>
 /// Returns a value indicating whether the current instance is a parent or grand-parent of
 /// the specified child item.
 /// </summary>
 /// <param name="child"></param>
 /// <returns></returns>
 public bool IsAParentOf(TreeViewItemViewModel child)
 {
     TreeViewItemViewModel parent = child;
     do
     {
         parent = parent.Parent;
         if (parent != null && parent == this) return true;
     }
     while (parent != null);
     // All parents compared, it's not our (grand-)child
     return false;
 }