Пример #1
0
        /// <summary>
        /// Clears the data column collection, then adds data column proxies, using a list of existing data column proxies. The proxies are cloned before adding them to the collection.
        /// </summary>
        /// <param name="fromList">The enumeration of data proxies to clone.</param>
        private void InternalSetDataColumnsWithCloning(Dictionary <string, ColumnBundleInfo> fromList)
        {
            if (null != _dataColumnBundles)
            {
                InternalClearDataColumnBundles();
            }
            else
            {
                _dataColumnBundles = new Dictionary <string, ColumnBundleInfo>();
            }

            _dataColumnBundles.Clear();
            foreach (var entry in fromList)
            {
                ColumnBundleInfo fromB = entry.Value;

                var thisB = new ColumnBundleInfo(fromB.MaximumNumberOfColumns);
                foreach (var fromMember in fromB.DataColumns)
                {
                    var clone = (IReadableColumnProxy)fromMember.Clone();
                    clone.ParentObject = this;
                    thisB.DataColumns.Add(clone);
                }

                _dataColumnBundles.Add(entry.Key, thisB);
            }
        }
Пример #2
0
 /// <summary>
 /// Adds a data column proxy to the data column collection without cloning it (i.e. the proxy is directly added).
 /// </summary>
 /// <param name="info">The bundle to which to add the column proxy.</param>
 /// <param name="proxy">The proxy.</param>
 private void InternalAddDataColumnNoClone(ColumnBundleInfo info, IReadableColumnProxy proxy)
 {
     if (null != proxy)
     {
         info.DataColumns.Add(proxy);
         proxy.ParentObject = this;
     }
 }
Пример #3
0
			public object Clone()
			{
				var result = new ColumnBundleInfo();
				result._maximumNumberOfColumns = this._maximumNumberOfColumns;
				foreach (var p in this._dataColumns)
					result._dataColumns.Add((IReadableColumnProxy)p.Clone());
				return result;
			}
Пример #4
0
        /// <summary>
        /// Removes the data column proxy at index <paramref name="idx"/> from the bundle of DataColumnProxies.
        /// </summary>
        /// <param name="bundle">Bundle of column proxies.</param>
        /// <param name="idx">The index.</param>
        private void InternalRemoveDataColumnAt(ColumnBundleInfo bundle, int idx)
        {
            var col = bundle.DataColumns[idx];

            bundle.DataColumns.RemoveAt(idx);
            if (null != col)
            {
                col.Dispose();
            }
        }
Пример #5
0
        /// <summary>
        /// Clear data columns collection, removes the event handlers from the data column proxies.
        /// </summary>
        private void InternalClearDataColumns(ColumnBundleInfo bundle)
        {
            var arr = bundle.DataColumns.ToArray();

            bundle.DataColumns.Clear();
            foreach (var proxy in arr)
            {
                proxy.Dispose();
            }
        }
Пример #6
0
            public object Clone()
            {
                var result = new ColumnBundleInfo
                {
                    _maximumNumberOfColumns = _maximumNumberOfColumns
                };

                foreach (var p in _dataColumns)
                {
                    result._dataColumns.Add((IReadableColumnProxy)p.Clone());
                }
                return(result);
            }
Пример #7
0
        /// <summary>
        /// Clears the data column collection of the provided bundle, then adds data column proxies, using a list of existing data column proxies. The proxies are cloned before adding them to the collection.
        /// </summary>
        /// <param name="bundle">Bundle in which to set the column proxies.</param>
        /// <param name="fromList">The enumeration of data proxies to clone.</param>
        private void InternalSetDataColumnsWithCloning(ColumnBundleInfo bundle, IEnumerable <IReadableColumnProxy> fromList)
        {
            if (null == bundle)
            {
                throw new ArgumentNullException("bundle");
            }

            InternalClearDataColumns(bundle);

            foreach (var fromMember in fromList)
            {
                var clone = (IReadableColumnProxy)fromMember.Clone();
                clone.ParentObject = this;
                bundle.DataColumns.Add(clone);
            }
        }
Пример #8
0
            protected virtual DataTableMultipleColumnProxy SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var s = (o == null ? new DataTableMultipleColumnProxy() : (DataTableMultipleColumnProxy)o);

                s.InternalSetDataTable((DataTableProxy)info.GetValue("Table", s));
                s._groupNumber = info.GetInt32("Group");

                s._useAllAvailableDataRows = info.GetBoolean("UseAllAvailableDataRows");

                int countBundles = info.OpenArray("DataColumnsBundles");

                for (int b = 0; b < countBundles; b++)
                {
                    info.OpenElement();
                    string identifier             = info.GetString("Identifier");
                    int?   MaximumNumberOfColumns = info.GetNullableInt32("MaximumNumberOfColumns");

                    var columnBundleInfo = new ColumnBundleInfo(MaximumNumberOfColumns);

                    int countColumns = info.OpenArray();
                    for (int i = 0; i < countColumns; i++)
                    {
                        s.InternalAddDataColumnNoClone(columnBundleInfo, (IReadableColumnProxy)info.GetValue("e", s));
                    }
                    info.CloseArray(countColumns);

                    s._dataColumnBundles.Add(identifier, columnBundleInfo);

                    info.CloseElement();
                }
                info.CloseArray(countBundles);

                if (!s._useAllAvailableDataRows)
                {
                    s._participatingDataRows = (AscendingIntegerCollection)info.GetValue("DataRows", s);
                }
                else
                {
                    s._participatingDataRows = new AscendingIntegerCollection();
                }

                s._isDirty = true;

                s._parent = parent as Main.IDocumentNode;
                return(s);
            }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataTableMultipleColumnProxy"/> class. The selected collections determine which columns and rows contribute to this instance.
        /// The group number is determined by the first selected column (or, if no column is selected, by the first column of the data table).
        /// </summary>
        /// <param name="identifier">The identifier of the bundle of columns that are initially set with this constructor.</param>
        /// <param name="table">The underlying table.</param>
        /// <param name="selectedDataRows">The selected data rows.</param>
        /// <param name="selectedDataColumns">The selected data columns.</param>
        /// <exception cref="System.ArgumentNullException">table must not be null.</exception>
        public DataTableMultipleColumnProxy(string identifier, DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }

            if (null == table)
            {
                throw new ArgumentNullException("table");
            }

            _dataColumnBundles = new Dictionary <string, ColumnBundleInfo>();

            _dataTable = new DataTableProxy(table)
            {
                ParentObject = this
            };

            _groupNumber = 0;

            if (null != selectedDataColumns && selectedDataColumns.Count > 0)
            {
                _groupNumber = table.DataColumns.GetColumnGroup(table[selectedDataColumns[0]]);
            }

            var bundle = new ColumnBundleInfo();

            _dataColumnBundles.Add(identifier, bundle);

            int maxRowCount = 0;

            if (selectedDataColumns != null && selectedDataColumns.Count > 0)
            {
                for (int i = 0; i < selectedDataColumns.Count; ++i)
                {
                    var col = table[selectedDataColumns[i]];
                    if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
                    {
                        InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
                        maxRowCount = Math.Max(maxRowCount, col.Count);
                    }
                }
            }
            else // nothing selected - use all columns of group number 0
            {
                for (int i = 0; i < table.DataColumnCount; ++i)
                {
                    var col = table[i];
                    if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
                    {
                        InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
                        maxRowCount = Math.Max(maxRowCount, col.Count);
                    }
                }
            }

            _useAllAvailableDataRows = null == selectedDataRows || selectedDataRows.Count == 0;

            _participatingDataRows = new AscendingIntegerCollection(_useAllAvailableDataRows ? ContiguousIntegerRange.FromStartAndCount(0, maxRowCount) : selectedDataRows);
        }
Пример #10
0
		/// <summary>
		/// Clears the data column collection, then adds data column proxies, using a list of existing data column proxies. The proxies are cloned before adding them to the collection.
		/// </summary>
		/// <param name="fromList">The enumeration of data proxies to clone.</param>
		private void InternalSetDataColumnsWithCloning(Dictionary<string, ColumnBundleInfo> fromList)
		{
			if (null != _dataColumnBundles)
			{
				InternalClearDataColumnBundles();
			}
			else
			{
				_dataColumnBundles = new Dictionary<string, ColumnBundleInfo>();
			}

			this._dataColumnBundles.Clear();
			foreach (var entry in fromList)
			{
				ColumnBundleInfo fromB = entry.Value;

				var thisB = new ColumnBundleInfo(fromB.MaximumNumberOfColumns);
				foreach (var fromMember in fromB.DataColumns)
				{
					var clone = (IReadableColumnProxy)fromMember.Clone();
					clone.ParentObject = this;
					thisB.DataColumns.Add(clone);
				}

				this._dataColumnBundles.Add(entry.Key, thisB);
			}
		}
Пример #11
0
		/// <summary>
		/// Clears the data column collection of the provided bundle, then adds data column proxies, using a list of existing data column proxies. The proxies are cloned before adding them to the collection.
		/// </summary>
		/// <param name="bundle">Bundle in which to set the column proxies.</param>
		/// <param name="fromList">The enumeration of data proxies to clone.</param>
		private void InternalSetDataColumnsWithCloning(ColumnBundleInfo bundle, IEnumerable<IReadableColumnProxy> fromList)
		{
			if (null == bundle)
				throw new ArgumentNullException("bundle");

			InternalClearDataColumns(bundle);

			foreach (var fromMember in fromList)
			{
				var clone = (IReadableColumnProxy)fromMember.Clone();
				clone.ParentObject = this;
				bundle.DataColumns.Add(clone);
			}
		}
Пример #12
0
		/// <summary>
		/// Removes the data column proxy at index <paramref name="idx"/> from the bundle of DataColumnProxies.
		/// </summary>
		/// <param name="bundle">Bundle of column proxies.</param>
		/// <param name="idx">The index.</param>
		private void InternalRemoveDataColumnAt(ColumnBundleInfo bundle, int idx)
		{
			var col = bundle.DataColumns[idx];
			bundle.DataColumns.RemoveAt(idx);
			if (null != col)
				col.Dispose();
		}
Пример #13
0
		/// <summary>
		/// Adds a data column proxy to the data column collection without cloning it (i.e. the proxy is directly added).
		/// </summary>
		/// <param name="info">The bundle to which to add the column proxy.</param>
		/// <param name="proxy">The proxy.</param>
		private void InternalAddDataColumnNoClone(ColumnBundleInfo info, IReadableColumnProxy proxy)
		{
			if (null != proxy)
			{
				info.DataColumns.Add(proxy);
				proxy.ParentObject = this;
			}
		}
Пример #14
0
		/// <summary>
		/// Clear data columns collection, removes the event handlers from the data column proxies.
		/// </summary>
		private void InternalClearDataColumns(ColumnBundleInfo bundle)
		{
			var arr = bundle.DataColumns.ToArray();
			bundle.DataColumns.Clear();
			foreach (var proxy in arr)
				proxy.Dispose();
		}
Пример #15
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DataTableMultipleColumnProxy"/> class. The selected collections determine which columns and rows contribute to this instance.
		/// The group number is determined by the first selected column (or, if no column is selected, by the first column of the data table).
		/// </summary>
		/// <param name="identifier">The identifier of the bundle of columns that are initially set with this constructor.</param>
		/// <param name="table">The underlying table.</param>
		/// <param name="selectedDataRows">The selected data rows.</param>
		/// <param name="selectedDataColumns">The selected data columns.</param>
		/// <exception cref="System.ArgumentNullException">table must not be null.</exception>
		public DataTableMultipleColumnProxy(string identifier, DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns)
		{
			if (null == identifier)
				throw new ArgumentNullException("identifier");

			if (null == table)
				throw new ArgumentNullException("table");

			_dataColumnBundles = new Dictionary<string, ColumnBundleInfo>();

			_dataTable = new DataTableProxy(table) { ParentObject = this };

			_groupNumber = 0;

			if (null != selectedDataColumns && selectedDataColumns.Count > 0)
				_groupNumber = table.DataColumns.GetColumnGroup(table[selectedDataColumns[0]]);

			var bundle = new ColumnBundleInfo();
			_dataColumnBundles.Add(identifier, bundle);

			int maxRowCount = 0;
			if (selectedDataColumns != null && selectedDataColumns.Count > 0)
			{
				for (int i = 0; i < selectedDataColumns.Count; ++i)
				{
					var col = table[selectedDataColumns[i]];
					if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
					{
						InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
						maxRowCount = Math.Max(maxRowCount, col.Count);
					}
				}
			}
			else // nothing selected - use all columns of group number 0
			{
				for (int i = 0; i < table.DataColumnCount; ++i)
				{
					var col = table[i];
					if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
					{
						InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
						maxRowCount = Math.Max(maxRowCount, col.Count);
					}
				}
			}

			_useAllAvailableDataRows = null == selectedDataRows || selectedDataRows.Count == 0;

			_participatingDataRows = new AscendingIntegerCollection(_useAllAvailableDataRows ? ContiguousIntegerRange.FromStartAndCount(0, maxRowCount) : selectedDataRows);
		}
Пример #16
0
			protected virtual DataTableMultipleColumnProxy SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				var s = (o == null ? new DataTableMultipleColumnProxy() : (DataTableMultipleColumnProxy)o);

				s.InternalSetDataTable((DataTableProxy)info.GetValue("Table", s));
				s._groupNumber = info.GetInt32("Group");

				s._useAllAvailableDataRows = info.GetBoolean("UseAllAvailableDataRows");

				int countBundles = info.OpenArray("DataColumnsBundles");
				for (int b = 0; b < countBundles; b++)
				{
					info.OpenElement();
					string identifier = info.GetString("Identifier");
					int? MaximumNumberOfColumns = info.GetNullableInt32("MaximumNumberOfColumns");

					var columnBundleInfo = new ColumnBundleInfo(MaximumNumberOfColumns);

					int countColumns = info.OpenArray();
					for (int i = 0; i < countColumns; i++)
					{
						s.InternalAddDataColumnNoClone(columnBundleInfo, (IReadableColumnProxy)info.GetValue("e", s));
					}
					info.CloseArray(countColumns);

					s._dataColumnBundles.Add(identifier, columnBundleInfo);

					info.CloseElement();
				}
				info.CloseArray(countBundles);

				if (!s._useAllAvailableDataRows)
				{
					s._participatingDataRows = (AscendingIntegerCollection)info.GetValue("DataRows", s);
				}
				else
				{
					s._participatingDataRows = new AscendingIntegerCollection();
				}

				s._isDirty = true;

				s._parent = parent as Main.IDocumentNode;
				return s;
			}