My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using System.ComponentModel;

namespace SyringeControl.WinForms
{
/// <summary>
/// Implementation of <see cref="INotifyingProperty{T}"/> storing list values.
/// Such values can be bound to controls via complex data binding (e.g. <see cref="System.Windows.Forms.BindingSource"/>.
/// </summary>
/// <typeparam name="TItem">type of items in list.</typeparam>
public class ListProperty<TItem> : PropertyBase<IList<TItem>>
{
/// <summary>
/// Initializes an instance of <see cref="SimpleProperty{T}"/> class.
/// </summary>
/// <param name="propName">name of property that will be passed to <see cref="INotifyingProperty{T}.Changed"/> handlers.</param>
public ListProperty(string propName)
: base(propName)
{
innerValue = new BindingList<TItem>();
}
/// <summary>
/// Sets property value.
/// Raises <see cref="INotifyingProperty{T}.Changed"/>.
/// </summary>
/// <param name="value">value to be stored in property</param>
/// <remarks>Actually this method don't replace inner value but clears it and fills with items from <paramref name="value"/>.
/// It forces the <see cref="System.Windows.Forms.BindingSource"/> to be notified about change;
/// </remarks>
public override void Set(IList<TItem> value)
{
var bList = (BindingList<TItem>)innerValue;
bList.RaiseListChangedEvents = false;
bList.Clear();
if (value != null)
foreach (var item in value)
bList.Add(item);
bList.RaiseListChangedEvents = true;
bList.ResetBindings();
InvokeChanged();
}
}
}

Change log

b4e5f52768aa by Yuri Korchyomkin <yuri.korchyomkin> on Aug 9, 2009   Diff
added to IControlView event notifying
about pressing 'Setup' button
moved some classes to separate files
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1849 bytes, 43 lines
Powered by Google Project Hosting