コード例 #1
0
        /// <summary>
        /// Updates the SelectedItems collection based on the content of
        /// the SelectedValue property.
        /// </summary>
        private void UpdateFromSelectedValue()
        {
            _ignoreSelectedItemsCollectionChanged++;
            // Just update the SelectedItems collection content
            // and let the synchronization be made from UpdateFromSelectedItems();
            SelectedItems.Clear();

            if (!String.IsNullOrEmpty(SelectedValue))
            {
                List <string>         selectedValues = SelectedValue.Split(new string[] { Delimiter }, StringSplitOptions.RemoveEmptyEntries).ToList();
                ValueEqualityComparer comparer       = new ValueEqualityComparer();

                foreach (object item in ItemsCollection)
                {
                    object itemValue = this.GetItemValue(item);

                    bool isSelected = (itemValue != null) &&
                                      selectedValues.Contains(itemValue.ToString(), comparer);

                    if (isSelected)
                    {
                        SelectedItems.Add(item);
                    }
                }
            }
            _ignoreSelectedItemsCollectionChanged--;

            this.UpdateFromSelectedItems();
        }
コード例 #2
0
ファイル: Selector.cs プロジェクト: ImmutableGlitch/Anathena
        internal void UpdateFromList(List <string> selectedValues, Func <object, object> GetItemfunction)
        {
            _ignoreSelectedItemsCollectionChanged++;
            // Just update the SelectedItems collection content
            // and let the synchronization be made from UpdateFromSelectedItems();
            SelectedItems.Clear();

            if ((selectedValues != null) && (selectedValues.Count > 0))
            {
                ValueEqualityComparer comparer = new ValueEqualityComparer();

                foreach (object item in ItemsCollection)
                {
                    object itemValue = GetItemfunction(item);

                    bool isSelected = (itemValue != null) &&
                                      selectedValues.Contains(itemValue.ToString(), comparer);

                    if (isSelected)
                    {
                        SelectedItems.Add(item);
                    }
                }
            }
            _ignoreSelectedItemsCollectionChanged--;

            this.UpdateFromSelectedItems();
        }
コード例 #3
0
        private static IComparer <Index> GetIndexComparer(MatrixDataOrder order)
        {
            IComparer <Index> comparer;

            if (order == MatrixDataOrder.Row)
            {
                comparer = new RowFirstIndexComparer();
            }
            else
            {
                comparer = new ColumnFirstIndexComparer();
            }
            return(comparer);
        }
コード例 #4
0
        public override Int32 GetHashCode()
        {
            var hash = 1374496523;

            unchecked {
                hash = (hash * -1521134295) + Id.GetHashCode();
                hash = (hash * -1521134295) + Modified.GetHashCode();
                hash = (hash * -1521134295) + Id.GetHashCode();
                if (IsTValueAValueType || !ReferenceEquals(Value, null))
                {
                    hash = (hash * -1521134295) + ValueEqualityComparer.GetHashCode(Value);
                }
            }
            return(hash);
        }
コード例 #5
0
 public Boolean Equals(VersionBase <TValue> version)
 {
     if (ReferenceEquals(version, null))
     {
         return(false);
     }
     if (ReferenceEquals(version, this))
     {
         return(true);
     }
     return(Id == version.Id &&
            VersionedId == version.VersionedId &&
            Added == version.Added &&
            ValueEqualityComparer.Equals(Value, version.Value));
 }
コード例 #6
0
 public Boolean Equals(TVersioned versioned)
 {
     if (ReferenceEquals(versioned, null))
     {
         return(false);
     }
     if (ReferenceEquals(versioned, this))
     {
         return(true);
     }
     return(Id == versioned.Id &&
            Modified == versioned.Modified &&
            IsReadOnly == versioned.IsReadOnly &&
            ValueEqualityComparer.Equals(Value, versioned.Value) &&
            (ReferenceEquals(LocalVersions, versioned.LocalVersions) || LocalVersions.SequenceEqual(versioned.LocalVersions)));
 }
コード例 #7
0
 internal void UpdateFromList(List <string> selectedValues, Func <object, object> GetItemfunction)
 {
     _ignoreSelectedItemsCollectionChanged++;
     SelectedItems.Clear();
     if (selectedValues != null && selectedValues.Count > 0)
     {
         ValueEqualityComparer comparer = new ValueEqualityComparer();
         foreach (object item in ItemsCollection)
         {
             object obj = GetItemfunction(item);
             if (obj != null && selectedValues.Contains(obj.ToString(), comparer))
             {
                 SelectedItems.Add(item);
             }
         }
     }
     _ignoreSelectedItemsCollectionChanged--;
     UpdateFromSelectedItems();
 }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Academy.Collections.Generic.SparseMatrix`1"/> class with specified dimensions, data order and default value.
        /// </summary>
        /// <param name="rowCount">The number of rows in the matrix.</param>
        /// <param name="columnCount">The number of columns in the matrix.</param>
        /// <param name="defaultValue">The value the matrix will assume as the default value.</param>
        /// <param name="dataOrder">The order the matrix will store elements in memory. 'Default' and 'Merged' values are used as 'Row' value.</param>
        public SparseMatrix(int rowCount, int columnCount, T defaultValue, MatrixDataOrder dataOrder)
        {
            if (dataOrder == MatrixDataOrder.Default)
            {
                dataOrder = MatrixDataOrder.Row;
            }
            this.order = dataOrder;
            IComparer <Index> comparer;

            if (dataOrder == MatrixDataOrder.Row)
            {
                comparer = new RowFirstIndexComparer();
            }
            else
            {
                comparer = new ColumnFirstIndexComparer();
            }
            dict          = new SortedDictionary <Index, T>(comparer);
            this.comparer = new ValueEqualityComparer();
            this.rowDim   = rowCount;
            this.colDim   = columnCount;
            this.count    = (long)rowCount * (long)columnCount;
            this.def      = defaultValue;
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Academy.Collections.Generic.SparseMatrix`1"/> class with specified dimensions, data order,
        /// default value and elements copied from the specified collection and positioned in the indices specified by the respective entries.
        /// </summary>
        /// <param name="entries">The collection whose elements are copied to the new matrix.</param>
        /// <param name="rowCount">The amount of rows of the matrix.</param>
        /// <param name="columnDimension">The amount of columns of the matrix.</param>
        /// <param name="defaultValue">The value the matrix will assume as the default value.</param>
        /// <param name="order">The order the matrix will store elements in memory. 'Default' and 'Merged' values are used as 'Row' value.</param>
        public SparseMatrix(IEnumerable <MatrixEntry <T> > entries, int rowCount, int columnDimension, T defaultValue, MatrixDataOrder order)
        {
            if (order != MatrixDataOrder.Column)
            {
                order = MatrixDataOrder.Row;
            }
            this.order = order;
            IComparer <Index> comparer;

            if (order == MatrixDataOrder.Row)
            {
                comparer = new RowFirstIndexComparer();
            }
            else
            {
                comparer = new ColumnFirstIndexComparer();
            }
            dict = new SortedDictionary <Index, T>(comparer);
            MatrixEntry <T> upperEntry = new MatrixEntry <T>(rowCount - 1, columnDimension - 1, default(T));

            this.def      = defaultValue;
            this.comparer = new ValueEqualityComparer();
            this.rowDim   = rowCount;
            this.colDim   = columnDimension;
            this.count    = (long)rowCount * (long)columnDimension;
            foreach (MatrixEntry <T> entry in entries)
            {
                int num  = entry.CompareTo(lowerEntry);
                int num2 = entry.CompareTo(upperEntry);
                if ((num < 0) || (num2 > 0))
                {
                    Thrower.ArgumentOutOfRangeException(ArgumentType.empty, Resources.ArgumentOutOfRange_EntryOutOfBounds);
                }
                DirectlySet(entry.RowIndex, entry.ColumnIndex, entry.Value);
            }
        }