本文整理汇总了C#中ObservableCollectionEx类的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollectionEx类的具体用法?C# ObservableCollectionEx怎么用?C# ObservableCollectionEx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObservableCollectionEx类属于命名空间,在下文中一共展示了ObservableCollectionEx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRangeOnlyRaisesOneCollectionChangedEventAtTheEnd
public void AddRangeOnlyRaisesOneCollectionChangedEventAtTheEnd()
{
var oc = new ObservableCollectionEx<string>();
var toAdd = new List<string>
{
"Foo",
"Bar"
};
var itemCount = 0;
var eventCount = 0;
var action = NotifyCollectionChangedAction.Add;
IList<string> addedItems = null;
oc.CollectionChanged += (sender, args) =>
{
++eventCount;
itemCount = oc.Count;
action = args.Action;
addedItems = args.NewItems.OfType<string>().ToList();
};
oc.AddRange(toAdd);
itemCount.Should().Be(2);
eventCount.Should().Be(1);
action.Should().Be(NotifyCollectionChangedAction.Add);
addedItems.Should().NotBeNull();
addedItems.ShouldBeEquivalentTo(toAdd);
}
示例2: UserDatabase
public UserDatabase()
{
XDocument doc = Open();
Users = new ObservableCollectionEx<User>(from u in doc.Descendants(Tags.User) select new User(u));
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
foreach (var user in Users)
{
foreach (var download in user.Downloads)
{
string path = Utils.MediaFilePath(user, download);
if (isf.FileExists(path))
{
using (var fileStream = isf.OpenFile(path, FileMode.Open))
{
download.DownloadedBytes = fileStream.Length;
}
}
}
}
}
Users.CollectionChanged += (sender, e) => { Save(true); };
}
示例3: RiskPanel
/// <summary>
/// Initializes a new instance of the <see cref="RiskPanel"/>.
/// </summary>
public RiskPanel()
{
InitializeComponent();
var ruleTypes = new[]
{
typeof(RiskCommissionRule),
typeof(RiskOrderFreqRule),
typeof(RiskOrderPriceRule),
typeof(RiskOrderVolumeRule),
typeof(RiskPnLRule),
typeof(RiskPositionSizeRule),
typeof(RiskPositionTimeRule),
typeof(RiskSlippageRule),
typeof(RiskTradeFreqRule),
typeof(RiskTradePriceRule),
typeof(RiskTradeVolumeRule)
};
_names.AddRange(ruleTypes.ToDictionary(t => t, t => t.GetDisplayName()));
TypeCtrl.ItemsSource = _names;
TypeCtrl.SelectedIndex = 0;
var itemsSource = new ObservableCollectionEx<RuleItem>();
RuleGrid.ItemsSource = itemsSource;
_rules = new ConvertibleObservableCollection<IRiskRule, RuleItem>(new ThreadSafeObservableCollection<RuleItem>(itemsSource), CreateItem);
}
示例4: UpdateProvider
private void UpdateProvider(ISecurityProvider provider)
{
if (_securityProvider == provider)
return;
if (_securityProvider != null)
{
_securityProvider.Added -= AddSecurities;
_securityProvider.Removed -= RemoveSecurities;
_securityProvider.Cleared -= ClearSecurities;
SecurityTextBox.ItemsSource = Enumerable.Empty<Security>();
_itemsSource = null;
}
_securityProvider = provider;
if (_securityProvider == null)
return;
var itemsSource = new ObservableCollectionEx<Security>();
_itemsSource = new ThreadSafeObservableCollection<Security>(itemsSource);
_itemsSource.AddRange(_securityProvider.LookupAll());
_securityProvider.Added += AddSecurities;
_securityProvider.Removed += RemoveSecurities;
_securityProvider.Cleared += ClearSecurities;
SecurityTextBox.ItemsSource = itemsSource;
}
示例5: BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded
public void BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded()
{
var col = new ObservableCollectionEx<object>();
col.Add(1);
Assert.IsTrue(true);
}
示例6: MainWindow
public MainWindow()
{
InitializeComponent();
var assetsSource = new ObservableCollectionEx<Security>();
var optionsSource = new ObservableCollectionEx<Security>();
Options.ItemsSource = optionsSource;
Assets.ItemsSource = assetsSource;
_assets = new ThreadSafeObservableCollection<Security>(assetsSource);
_options = new ThreadSafeObservableCollection<Security>(optionsSource);
// попробовать сразу найти месторасположение Quik по запущенному процессу
Path.Text = QuikTerminal.GetDefaultPath();
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) };
timer.Tick += (sender, args) =>
{
if (!_isDirty)
return;
_isDirty = false;
RefreshChart();
};
timer.Start();
//
// добавляем тестовый данные для отображения графика
var asset = new Security { Id = "[email protected]" };
Connector = new FakeConnector(new[] { asset });
PosChart.AssetPosition = new Position
{
Security = asset,
CurrentValue = -1,
};
PosChart.MarketDataProvider = Connector;
PosChart.SecurityProvider = Connector;
var expDate = new DateTime(2014, 6, 14);
PosChart.Positions.Add(new Position
{
Security = new Security { Code = "RI C 110000", Strike = 110000, ImpliedVolatility = 45, OptionType = OptionTypes.Call, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id },
CurrentValue = 10,
});
PosChart.Positions.Add(new Position
{
Security = new Security { Code = "RI P 95000", Strike = 95000, ImpliedVolatility = 30, OptionType = OptionTypes.Put, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id },
CurrentValue = -3,
});
PosChart.Refresh(100000, 10, new DateTime(2014, 5, 5), expDate);
Instance = this;
}
示例7: CommissionPanel
/// <summary>
/// Initializes a new instance of the <see cref="CommissionPanel"/>.
/// </summary>
public CommissionPanel()
{
InitializeComponent();
var itemsSource = new ObservableCollectionEx<RuleItem>();
RuleGrid.ItemsSource = itemsSource;
_rules = new ConvertibleObservableCollection<ICommissionRule, RuleItem>(new ThreadSafeObservableCollection<RuleItem>(itemsSource), CreateItem);
var ruleTypes = new[]
{
typeof(CommissionPerOrderCountRule),
typeof(CommissionPerOrderRule),
typeof(CommissionPerOrderVolumeRule),
typeof(CommissionPerTradeCountRule),
typeof(CommissionPerTradePriceRule),
typeof(CommissionPerTradeRule),
typeof(CommissionPerTradeVolumeRule),
typeof(CommissionSecurityIdRule),
typeof(CommissionSecurityTypeRule),
typeof(CommissionTurnOverRule),
typeof(CommissionBoardCodeRule)
};
_names.AddRange(ruleTypes.ToDictionary(t => t, t => t.GetDisplayName()));
TypeCtrl.ItemsSource = _names;
TypeCtrl.SelectedIndex = 0;
}
示例8: Device
public Device(Guid id, string name, string description = null, ISpatialLocation location = null)
: base(id, name, description)
{
Location = location;
Recordables = new ObservableCollectionEx<IRecordable, Guid>();
Recordables.Added.Subscribe(OnRecordablesAdded);
Recordables.Removed.Subscribe(OnRecordablesRemoved);
}
示例9: PortfolioPickerWindow
/// <summary>
/// Initializes a new instance of the <see cref="PortfolioPickerWindow"/>.
/// </summary>
public PortfolioPickerWindow()
{
InitializeComponent();
var itemsSource = new ObservableCollectionEx<Portfolio>();
PortfoliosCtrl.ItemsSource = itemsSource;
Portfolios = new ThreadSafeObservableCollection<Portfolio>(itemsSource);
}
示例10: CandlesWindow
public CandlesWindow()
{
InitializeComponent();
var candlesSource = new ObservableCollectionEx<QuikCandle>();
CandleDetails.ItemsSource = candlesSource;
Candles = new ThreadSafeObservableCollection<QuikCandle>(candlesSource);
}
示例11: SearchItemEditWindow
public SearchItemEditWindow(ref SearchItem searchItem)
{
_searchItem = searchItem;
InitializeComponent();
{
var icon = new BitmapImage();
icon.BeginInit();
icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
icon.EndInit();
if (icon.CanFreeze) icon.Freeze();
this.Icon = icon;
}
lock (_searchItem.ThisLock)
{
_searchTreeViewItemNameTextBox.Text = _searchItem.Name;
_nameCollection = new ObservableCollectionEx<SearchContains<string>>(_searchItem.SearchNameCollection);
_nameRegexCollection = new ObservableCollectionEx<SearchContains<SearchRegex>>(_searchItem.SearchNameRegexCollection);
_signatureCollection = new ObservableCollectionEx<SearchContains<SearchRegex>>(_searchItem.SearchSignatureCollection);
_keywordCollection = new ObservableCollectionEx<SearchContains<string>>(_searchItem.SearchKeywordCollection);
_creationTimeRangeCollection = new ObservableCollectionEx<SearchContains<SearchRange<DateTime>>>(_searchItem.SearchCreationTimeRangeCollection);
_lengthRangeCollection = new ObservableCollectionEx<SearchContains<SearchRange<long>>>(_searchItem.SearchLengthRangeCollection);
_seedCollection = new ObservableCollectionEx<SearchContains<Seed>>(_searchItem.SearchSeedCollection);
_stateCollection = new ObservableCollectionEx<SearchContains<SearchState>>(_searchItem.SearchStateCollection);
}
_searchTreeViewItemNameTextBox_TextChanged(null, null);
_nameListView.ItemsSource = _nameCollection;
_nameRegexListView.ItemsSource = _nameRegexCollection;
_signatureListView.ItemsSource = _signatureCollection;
_keywordListView.ItemsSource = _keywordCollection;
_creationTimeRangeListView.ItemsSource = _creationTimeRangeCollection;
_lengthRangeListView.ItemsSource = _lengthRangeCollection;
_seedListView.ItemsSource = _seedCollection;
_stateListView.ItemsSource = _stateCollection;
_nameListViewUpdate();
_nameRegexListViewUpdate();
_signatureListViewUpdate();
_keywordListViewUpdate();
_creationTimeRangeListViewUpdate();
_lengthRangeListViewUpdate();
_seedListViewUpdate();
_stateListViewUpdate();
foreach (var item in Enum.GetValues(typeof(SearchState)).Cast<SearchState>())
{
_stateComboBox.Items.Add(item);
}
_stateComboBox.SelectedIndex = 0;
}
示例12: MyTradeGrid
/// <summary>
/// Initializes a new instance of the <see cref="MyTradeGrid"/>.
/// </summary>
public MyTradeGrid()
{
InitializeComponent();
var itemsSource = new ObservableCollectionEx<MyTrade>();
ItemsSource = itemsSource;
_trades = new ThreadSafeObservableCollection<MyTrade>(itemsSource) { MaxCount = 10000 };
}
示例13: OrderLogGrid
/// <summary>
/// Initializes a new instance of the <see cref="OrderLogGrid"/>.
/// </summary>
public OrderLogGrid()
{
InitializeComponent();
var itemsSource = new ObservableCollectionEx<OrderLogItem>();
ItemsSource = itemsSource;
_items = new ThreadSafeObservableCollection<OrderLogItem>(itemsSource) { MaxCount = 100000 };
}
示例14: ImageShrinkerViewModel
public ImageShrinkerViewModel()
{
ImageThumbs = new ObservableCollectionEx<ImageThumbViewModel>();
Scale = 100;
Quality = 90;
ArchiveName = "BilderArchiv";
_filenames = new Dictionary<string, string>();
_selectedThumb = null;
}
示例15: Level1Grid
/// <summary>
/// Initializes a new instance of the <see cref="Level1Grid"/>.
/// </summary>
public Level1Grid()
{
InitializeComponent();
var itemsSource = new ObservableCollectionEx<Level1ChangeMessage>();
ItemsSource = itemsSource;
_messages = new ThreadSafeObservableCollection<Level1ChangeMessage>(itemsSource) { MaxCount = 10000 };
}