Exemple #1
0
 public void SetSource(IListDataSource source, IBackend sourceBackend)
 {
     this.source           = source;
     tsource               = new ComboDataSource(source);
     Widget.UsesDataSource = true;
     Widget.DataSource     = tsource;
 }
 public void SetSource(IListDataSource source, IBackend sourceBackend)
 {
     tsource               = new ComboDataSource(source);
     tsource.TextColumn    = textColumn;
     Widget.UsesDataSource = true;
     Widget.DataSource     = tsource;
 }
        public void BindingContext_Item_GetIListSourceDataSourceWithDataMemberReturningIList_AddsToCollection()
        {
            var context = new BindingContext();
            var list    = new List <int> {
                1, 2, 3
            };
            var dataSource      = new IListDataSource();
            var mockIListSource = new Mock <IListSource>(MockBehavior.Strict);

            mockIListSource
            .Setup(s => s.GetList())
            .Returns(list);
            Mock <IList> mockIList = mockIListSource.As <IList>();

            dataSource.Property = mockIList.Object;

            CurrencyManager manager = Assert.IsAssignableFrom <CurrencyManager>(context[dataSource, "Property"]);

            Assert.Same(list, manager.List);
            Assert.Equal(1, manager.Current);
            Assert.Equal(3, manager.Count);
            Assert.Equal(0, manager.Position);
            Assert.Equal(2, ((ICollection)context).Count);
            Assert.Same(manager, context[dataSource, "Property"]);
        }
 CustomListModel GetListModel(IListDataSource source)
 {
     CustomListModel model;
     if (!modelCache.TryGetValue (source, out model))
         modelCache [new DataSourceRef (source)] = model = new CustomListModel (source, CellRendererTarget.EventRootWidget);
     return model;
 }
Exemple #5
0
        public void SetSource(IListDataSource s, IBackend sourceBackend)
        {
            if (source != null)
            {
                source.RowInserted   -= HandleSourceRowInserted;
                source.RowDeleted    -= HandleSourceRowDeleted;
                source.RowChanged    -= HandleSourceRowChanged;
                source.RowsReordered -= HandleSourceRowsReordered;
            }

            source      = s;
            Widget.Menu = new NSMenu();

            if (source != null)
            {
                source.RowInserted   += HandleSourceRowInserted;
                source.RowDeleted    += HandleSourceRowDeleted;
                source.RowChanged    += HandleSourceRowChanged;
                source.RowsReordered += HandleSourceRowsReordered;
                for (int n = 0; n < source.RowCount; n++)
                {
                    NSMenuItem it = new NSMenuItem();
                    UpdateItem(it, n);
                    Widget.Menu.AddItem(it);
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// Mark or unmark all items
 /// </summary>
 public static void MarkAll(this IListDataSource source, bool value)
 {
     for (var i = 0; i < source.Count; i++)
     {
         source.SetMark(i, value);
     }
 }
Exemple #7
0
        public virtual void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            this.source = source;

            RowHeights = new List <nfloat> ();
            for (int i = 0; i < source.RowCount; i++)
            {
                RowHeights.Add(-1);
            }

            tsource          = new ListSource(source);
            Table.DataSource = tsource;

            //TODO: Reloading single rows would be slightly more efficient.
            //      According to NSTableView.ReloadData() documentation,
            //      only the visible rows are reloaded.
            source.RowInserted += (sender, e) => {
                RowHeights.Insert(e.Row, -1);
                Table.ReloadData();
            };
            source.RowDeleted += (sender, e) => {
                RowHeights.RemoveAt(e.Row);
                Table.ReloadData();
            };
            source.RowChanged += (sender, e) => {
                UpdateRowHeight(e.Row);
                Table.ReloadData(NSIndexSet.FromIndex(e.Row), NSIndexSet.FromNSRange(new NSRange(0, Table.ColumnCount)));
            };
            source.RowsReordered += (sender, e) => { RowHeights.Clear(); Table.ReloadData(); };
        }
Exemple #8
0
 CustomListModel GetListModel(IListDataSource source)
 {
     CustomListModel model;
     if (!modelCache.TryGetValue (source, out model))
         modelCache [new DataSourceRef (source)] = model = new CustomListModel (source, CellRendererTarget.EventRootWidget);
     return model;
 }
Exemple #9
0
		public void SetSource (IListDataSource source, IBackend sourceBackend)
		{
			var dataSource = sourceBackend as ListDataSource;
			if (dataSource != null)
				ComboBox.ItemsSource = dataSource;
			else
				ComboBox.ItemsSource = new ListSourceNotifyWrapper (source);
		}
 public void SetSource(IListDataSource source, IBackend sourceBackend)
 {
     ListStoreBackend b = sourceBackend as ListStoreBackend;
     if (b == null) {
         CustomListModel model = new CustomListModel (source, Widget);
         Widget.Model = model.Store;
     } else
         Widget.Model = b.Store;
 }
Exemple #11
0
		public override void SetSource (IListDataSource source, IBackend sourceBackend)
		{
			base.SetSource (source, sourceBackend);

			source.RowInserted += HandleColumnSizeChanged;
			source.RowDeleted += HandleColumnSizeChanged;
			source.RowChanged += HandleColumnSizeChanged;
			ResetColumnSize (source);
		}
Exemple #12
0
        public override void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            base.SetSource(source, sourceBackend);

            source.RowInserted += HandleColumnSizeChanged;
            source.RowDeleted  += HandleColumnSizeChanged;
            source.RowChanged  += HandleColumnSizeChanged;
            ResetColumnSize(source);
        }
        public ComboDataSource(IListDataSource source)
        {
            this.source = source;

            source.RowChanged    += SourceChanged;
            source.RowDeleted    += SourceChanged;
            source.RowInserted   += SourceChanged;
            source.RowsReordered += SourceChanged;
        }
Exemple #14
0
		public CustomListModel (IListDataSource source, Gtk.Widget w)
		{
			parent = w;
			this.source = source;
			adapter = new Gtk.TreeModelAdapter (this);
			colTypes = source.ColumnTypes;
			source.RowChanged += HandleRowChanged;
			source.RowDeleted += HandleRowDeleted;
			source.RowInserted += HandleRowInserted;
			source.RowsReordered += HandleRowsReordered;
		}
        public DataSourceNotifyWrapper(IListDataSource source)
        {
            if (source == null)
                throw new ArgumentNullException ("source");

            this.source = source;
            this.source.RowInserted += OnRowsUpdated;
            this.source.RowChanged += OnRowsUpdated;
            this.source.RowsReordered += OnRowsUpdated;
            this.source.RowDeleted += OnRowsUpdated;
        }
Exemple #16
0
 public CustomListModel(IListDataSource source, Gtk.Widget w)
 {
     parent                = w;
     this.source           = source;
     adapter               = new Gtk.TreeModelAdapter(this);
     colTypes              = source.ColumnTypes;
     source.RowChanged    += HandleRowChanged;
     source.RowDeleted    += HandleRowDeleted;
     source.RowInserted   += HandleRowInserted;
     source.RowsReordered += HandleRowsReordered;
 }
 protected override void Dispose(bool disposing)
 {
     if (source != null)
     {
         source.RowChanged    -= SourceChanged;
         source.RowDeleted    -= SourceChanged;
         source.RowInserted   -= SourceChanged;
         source.RowsReordered -= SourceChanged;
         source = null;
     }
     base.Dispose(disposing);
 }
Exemple #18
0
        /// <summary>
        /// Return true if all items are marked or unmarked
        /// </summary>
        public static bool All(this IListDataSource source, bool value)
        {
            for (int i = 0; i < source.Count; i++)
            {
                if (source.IsMarked(i) != value)
                {
                    return(false);
                }
            }

            return(true);
        }
        public ListSourceNotifyWrapper(IListDataSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.source                = source;
            this.source.RowInserted   += OnRowsUpdated;
            this.source.RowChanged    += OnRowsUpdated;
            this.source.RowsReordered += OnRowsUpdated;
            this.source.RowDeleted    += OnRowsUpdated;
        }
Exemple #20
0
        public void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            var dataSource = sourceBackend as ListDataSource;

            if (dataSource != null)
            {
                ListView.ItemsSource = dataSource;
            }
            else
            {
                ListView.ItemsSource = new ListSourceNotifyWrapper(source);
            }
        }
Exemple #21
0
        public void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            ListStoreBackend b = sourceBackend as ListStoreBackend;

            if (b == null)
            {
                CustomListModel model = new CustomListModel(source, Widget);
                Widget.Model = model.Store;
            }
            else
            {
                Widget.Model = b.Store;
            }
        }
Exemple #22
0
        public virtual void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            this.source      = source;
            tsource          = new ListSource(source);
            Table.DataSource = tsource;

            //TODO: Reloading single rows would be slightly more efficient.
            //      According to NSTableView.ReloadData() documentation,
            //      only the visible rows are reloaded.
            source.RowInserted   += (sender, e) => Table.ReloadData();
            source.RowDeleted    += (sender, e) => Table.ReloadData();
            source.RowChanged    += (sender, e) => Table.ReloadData();
            source.RowsReordered += (sender, e) => Table.ReloadData();
        }
Exemple #23
0
        public void BindingContext_Item_GetArrayWithDataMember_AddsToCollection()
        {
            var context    = new BindingContext();
            var list       = new int[] { 1, 2, 3 };
            var dataSource = new IListDataSource();

            dataSource.Property = list;

            CurrencyManager manager = Assert.IsAssignableFrom <CurrencyManager>(context[dataSource, "Property"]);

            Assert.Same(list, manager.List);
            Assert.Equal(1, manager.Current);
            Assert.Equal(3, manager.Count);
            Assert.Equal(0, manager.Position);
            Assert.Equal(2, ((ICollection)context).Count);
            Assert.Same(manager, context[dataSource, "Property"]);
        }
Exemple #24
0
        void ResetColumnSize(IListDataSource source)
        {
            // Calculate size of column
            // This is how Apple implements it; unfortunately, they don't expose this functionality in the API.
            // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/NSTableViewDelegate/tableView:sizeToFitWidthOfColumn:
            float w = 0;

            for (var row = 0; row < source.RowCount; row++)
            {
                using (var cell = Table.GetCell(0, row)) {
                    var size = cell.CellSize;
                    w = Math.Max(w, size.Width);
                }
            }
            columnHandle.MinWidth = w;
            columnHandle.Width    = w;
        }
        public void BindingContext_Item_GetIListSourceDataSourceWithDataMemberReturningIListNull_ThrowsArgumentNullException()
        {
            var context         = new BindingContext();
            var dataSource      = new IListDataSource();
            var mockIListSource = new Mock <IListSource>(MockBehavior.Strict);

            mockIListSource
            .Setup(s => s.GetList())
            .Returns((IList)null);
            Mock <IList> mockIList = mockIListSource.As <IList>();

            dataSource.Property = mockIList.Object;

            Assert.Throws <ArgumentNullException>("dataSource", () => context[dataSource, "Property"]);

            // Does, however, add the parent.
            PropertyManager parentManager = Assert.IsType <PropertyManager>(Assert.IsType <WeakReference>(Assert.IsType <DictionaryEntry>(Assert.Single(context)).Value).Target);

            Assert.Same(dataSource, parentManager.Current);
        }
Exemple #26
0
        public void BindToGridAndDataSource(DataGrid dataGrid, IListDataSource dataSource, ListFilter filter)
        {
            if (dataGrid == null)
            {
                throw new ArgumentNullException("dataGrid");
            }
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            _dataGrid   = dataGrid;
            _dataSource = dataSource;
            _filter     = filter;

            UpdateGridItemsSource();
        }
            /// <summary>
            /// Gets the list of data from the associated <see cref="IListDataSource"/> control and
            /// applies the specified filter and sort expression.
            /// </summary>
            /// <param name="arguments">A System.Web.UI.DataSourceSelectArguments that
            /// is used to request operations on the data beyond basic data retrieval.</param>
            /// <returns>An System.Collections.IEnumerable list of data from the associated EntityDataSource.</returns>
            protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
            {
                IListDataSource dataSource = _owner.GetListDataSource();
                IEnumerable     entityList = null;

                if (dataSource != null)
                {
                    entityList = dataSource.GetEntityList();
                }
                else
                {
                    _owner.DataBind();

                    if (_owner.DataSource is IEnumerable)
                    {
                        entityList = _owner.DataSource as IEnumerable;
                    }
                }

                if (entityList != null)
                {
                    // apply filter
                    OnApplyFilter(entityList);

                    if (!String.IsNullOrEmpty(Filter))
                    {
                        EntityUtil.SetPropertyValue(entityList, "Filter", Filter);
                    }

                    // apply sort
                    OnApplySort(entityList);

                    if (!String.IsNullOrEmpty(Sort))
                    {
                        EntityUtil.InvokeMethod(entityList, "Sort", new Object[] { Sort });
                    }
                }

                return(entityList);
            }
Exemple #28
0
		/// <summary>
		/// Updates and returns the value of the DataParameter object.
		/// </summary>
		/// <param name="context">The current System.Web.HttpContext of the request.</param>
		/// <param name="control">The System.Web.UI.Control that the parameter is bound to.</param>
		/// <returns>A System.Object that represents the updated and current value of the parameter.</returns>
		protected override Object Evaluate(HttpContext context, Control control)
		{
			String value = String.Empty;

			if ( _dataSource == null && control != null )
			{
				_dataSource = control.FindControl(DataSourceID) as IListDataSource;
			}
			if ( _dataSource != null )
			{
				IEnumerable entityList = _dataSource.GetEntityList();

				if ( entityList != null )
				{
					CommaDelimitedStringCollection values = new CommaDelimitedStringCollection();
					String propertyName = PropertyName ?? EntityKeyName;
					IList list = EntityUtil.GetEntityList(entityList);
					Object temp;

					foreach ( Object item in list )
					{
						temp = EntityUtil.GetPropertyValue(item, EntityKeyName);

						if ( temp != null )
						{
							values.Add(String.Format("'{0}'", temp));
						}
					}

					if ( values.Count > 0 )
					{
						value = String.Format("{0} IN ({1})", propertyName, values.ToString());
					}
				}
			}

			return value;
		}
Exemple #29
0
        /// <summary>
        /// Updates and returns the value of the DataParameter object.
        /// </summary>
        /// <param name="context">The current System.Web.HttpContext of the request.</param>
        /// <param name="control">The System.Web.UI.Control that the parameter is bound to.</param>
        /// <returns>A System.Object that represents the updated and current value of the parameter.</returns>
        protected override Object Evaluate(HttpContext context, Control control)
        {
            String value = String.Empty;

            if (_dataSource == null && control != null)
            {
                _dataSource = control.FindControl(DataSourceID) as IListDataSource;
            }
            if (_dataSource != null)
            {
                IEnumerable entityList = _dataSource.GetEntityList();

                if (entityList != null)
                {
                    CommaDelimitedStringCollection values = new CommaDelimitedStringCollection();
                    String propertyName = PropertyName ?? EntityKeyName;
                    IList  list         = EntityUtil.GetEntityList(entityList);
                    Object temp;

                    foreach (Object item in list)
                    {
                        temp = EntityUtil.GetPropertyValue(item, EntityKeyName);

                        if (temp != null)
                        {
                            values.Add(String.Format("'{0}'", temp));
                        }
                    }

                    if (values.Count > 0)
                    {
                        value = String.Format("{0} IN ({1})", propertyName, values.ToString());
                    }
                }
            }

            return(value);
        }
        public void BindingContext_UpdateBinding_NewListBindingWithDataMember_Success()
        {
            var context = new BindingContext();
            var list    = new List <int> {
                1, 2, 3
            };
            var dataSource = new IListDataSource {
                Property = list
            };
            var binding = new Binding(null, dataSource, "Property.ignore");

            BindingContext.UpdateBinding(context, binding);
            Assert.Equal(2, ((ICollection)context).Count);

            CurrencyManager manager = Assert.IsAssignableFrom <CurrencyManager>(context[dataSource, "Property"]);

            Assert.Same(binding, Assert.Single(manager.Bindings));
            Assert.Same(list, manager.List);
            Assert.Equal(1, manager.Current);
            Assert.Equal(3, manager.Count);
            Assert.Equal(0, manager.Position);
            Assert.Same(manager, binding.BindingManagerBase);
        }
Exemple #31
0
 public ListSource(IListDataSource source)
 {
     this.source = source;
 }
Exemple #32
0
 /// <summary>
 ///     Initializes a new ListView that will display the provided data source  with an absolute position
 /// </summary>
 /// <param name="rect">Frame for the listview.</param>
 /// <param name="source">
 ///     IListDataSource object that provides a mechanism to render the data. The number of elements on the
 ///     collection should not change, if you must change, set the "Source" property to reset the internal settings of the
 ///     ListView.
 /// </param>
 public ListView(Rect rect, IListDataSource source) : base(rect)
 {
     Source   = source;
     CanFocus = true;
 }
 public CustomListView(IListDataSource source) : base(source)
 {
 }
Exemple #34
0
 public ListView(IListDataSource source) : this()
 {
     VerifyConstructorCall(this);
     DataSource = source;
 }
Exemple #35
0
 public ListView(IListDataSource source) : this()
 {
     DataSource = source;
 }
 public DataSourceRef(IListDataSource dataSource)
 {
     hash = dataSource.GetHashCode ();
     source = new WeakReference (dataSource);
 }
Exemple #37
0
 public ComboDataSource(IListDataSource source)
 {
     this.source = source;
 }
Exemple #38
0
 public void SetSource(IListDataSource source, IBackend sourceBackend)
 {
     this.source      = source;
     tsource          = new ListSource(source);
     Table.DataSource = tsource;
 }
Exemple #39
0
 public void SetSource(IListDataSource source, IBackend sourceBackend)
 {
     ComboBox.ItemsSource = new DataSourceNotifyWrapper (source);
 }
Exemple #40
0
 void ResetColumnSize(IListDataSource source)
 {
     // Calculate size of column
     // This is how Apple implements it; unfortunately, they don't expose this functionality in the API.
     // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/NSTableViewDelegate/tableView:sizeToFitWidthOfColumn:
     nfloat w = 0;
     for (var row = 0; row < source.RowCount; row++) {
         using (var cell = Table.GetCell (0, row)) {
             var size = cell.CellSize;
             w = (nfloat)Math.Max (w, size.Width);
         }
     }
     columnHandle.MinWidth = (nfloat)Math.Ceiling (w);
     columnHandle.Width = (nfloat)Math.Ceiling (w);
 }
Exemple #41
0
 public ListView(IListDataSource source)
     : this()
 {
     DataSource = source;
 }