public void ObservableCollectionEx_TestRemoveRange() { ObservableCollectionEx <int> collection = new ObservableCollectionEx <int>(); List <int> list = new List <int>(); for (var i = 1; i <= 300000; i++) { list.Add(i); } collection.AddRange(list); Assert.AreEqual(300000, collection.Count); collection.RemoveRange(100000); Assert.AreEqual(200000, collection.Count); Assert.AreEqual(100001, collection[0]); Assert.AreEqual(100050, collection[49]); Assert.AreEqual(100051, collection[50]); Assert.AreEqual(100100, collection[99]); Assert.AreEqual(300000, collection[collection.Count - 1]); collection.RemoveRange(50, 50); Assert.AreEqual(199950, collection.Count); Assert.AreEqual(100050, collection[49]); Assert.AreEqual(100101, collection[50]); Assert.AreEqual(100150, collection[99]); Assert.AreEqual(300000, collection[collection.Count - 1]); }
public async void Execute_OnSearchClick() { if (Searching) { return; } Searching = true; DispatcherService.InvokeIfRequired(() => _tweets.Clear()); if (_tweetSearchService != null && !string.IsNullOrEmpty(SearchString)) { await _tweetSearchService.GetMeSomeTweets <LinqTweet>(newTweets => { if (newTweets != null) { DispatcherService.InvokeIfRequired(() => _tweets.AddRange(newTweets)); } Searching = false; if (OnSearchComplete != null) { OnSearchComplete(); } }, SearchString); } }
private void Update() { this.NotifyPropertyChanged(nameof(this.Name)); { var tempList = new List <SignatureTreeViewModel>(); foreach (var item in _value.Children) { tempList.Add(new SignatureTreeViewModel(this, item)); } tempList.Sort((x, y) => { int c = x.Value.LinkItem.Signature.CompareTo(y.Value.LinkItem.Signature); if (c != 0) { return(c); } return(x.GetHashCode().CompareTo(y.GetHashCode())); }); _children.Clear(); _children.AddRange(tempList); } }
/// <summary> /// Создать <see cref="ExchangeBoardComboBox"/>. /// </summary> public ExchangeBoardComboBox() { IsEditable = true; var provider = ConfigManager.TryGetService <IExchangeInfoProvider>(); if (provider == null) { Boards = new ObservableCollectionEx <ExchangeBoard> { _emptyBoard }; Boards.AddRange(ExchangeBoard.EnumerateExchangeBoards().OrderBy(b => b.Code)); ConfigManager.ServiceRegistered += ConfigManagerServiceRegistered; } else { FillBoards(provider); } ItemsSource = Boards; DisplayMemberPath = "Code"; SelectedBoard = _emptyBoard; }
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); }
public MulticastMessageEditWindow(Tag tag, string comment, AmoebaManager amoebaManager) { _tag = tag; _amoebaManager = amoebaManager; _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray()); InitializeComponent(); this.Title = LanguagesManager.Instance.MulticastMessageEditWindow_Title + " - " + MessageConverter.ToTagString(tag); { var icon = new BitmapImage(); icon.BeginInit(); icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read); icon.EndInit(); if (icon.CanFreeze) { icon.Freeze(); } this.Icon = icon; } _signatureComboBox.ItemsSource = _digitalSignatureCollection; _signatureComboBox.SelectedIndex = 0; _commentTextBox.Text = comment; _watchTimer = new WatchTimer(this.WatchThread, 0, 1000); this.Closed += (sender, e) => _watchTimer.Dispose(); _textEditor_Helper.Setup(_textEditor); }
public static ObservableCollectionEx <T> ToObservableCollectionEx <T>(this IEnumerable <T> source) where T : INotifyPropertyChanged { var collection = new ObservableCollectionEx <T>(); collection.AddRange(source.ToList()); // Not entirely sure why the ToList is needed here, BUT IT IS! return(collection); }
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); }
public TS_part(TS_materials.TS_material material, TS_contour contour, List <TS_void> voids) { Material = material; Voids = new ObservableCollectionEx <TS_void>(); Contour = contour; Voids.AddRange(voids); GeometryComponents = null; CalcProperties(); }
public void ObservableCollectionEx_TestAddRange() { ObservableCollectionEx <int> collection = new ObservableCollectionEx <int>(); List <int> list = new List <int>(); for (var i = 1; i <= 300000; i++) { list.Add(i); } collection.AddRange(list); Assert.AreEqual(300000, collection.Count); }
public void AddRangeDoesntRaiseAnEventIfNothingIsAdded() { var oc = new ObservableCollectionEx <string> { "Foo", "Bar" }; var toAdd = new List <string>(); oc.MonitorEvents(); oc.AddRange(toAdd); oc.ShouldNotRaise("CollectionChanged"); }
public void AddRangeDoesntRaiseAnEventIfNothingIsAdded() { var oc = new ObservableCollectionEx<string> { "Foo", "Bar" }; var toAdd = new List<string>(); oc.MonitorEvents(); oc.AddRange(toAdd); oc.ShouldNotRaise("CollectionChanged"); }
public void AddRangeAddsAllTheItems() { var oc = new ObservableCollectionEx <string>(); var toAdd = new List <string> { "Foo", "Bar" }; oc.AddRange(toAdd); oc.Should().ContainInOrder(toAdd); oc.Should().OnlyContain(s => toAdd.Contains(s)); oc.Count.Should().Be(2); }
public void AddRangeAddsAllTheItems() { var oc = new ObservableCollectionEx<string>(); var toAdd = new List<string> { "Foo", "Bar" }; oc.AddRange(toAdd); oc.Should().ContainInOrder(toAdd); oc.Should().OnlyContain(s => toAdd.Contains(s)); oc.Count.Should().Be(2); }
private void _treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { var selectTreeViewItem = _treeView.SelectedItem as SignatureTreeViewModel; if (selectTreeViewItem == null) { return; } _trustSignatureCollection.Clear(); _trustSignatureCollection.AddRange(selectTreeViewItem.Value.LinkItem.TrustSignatures); _untrustSignatureCollection.Clear(); _untrustSignatureCollection.AddRange(selectTreeViewItem.Value.LinkItem.DeleteSignatures); this.Update_Title(); }
public void ObservableCollectionEx_TestInsertRange() { ObservableCollectionEx <int> collection = new ObservableCollectionEx <int>(); List <int> list = new List <int>(); for (var i = 200001; i <= 300000; i++) { list.Add(i); } collection.AddRange(list); Assert.AreEqual(100000, collection.Count); Assert.AreEqual(300000, collection[collection.Count - 1]); list = new List <int>(); for (var i = 1; i <= 100000; i++) { list.Add(i); } collection.InsertRange(list); Assert.AreEqual(200000, collection.Count); Assert.AreEqual(1, collection[0]); Assert.AreEqual(100000, collection[99999]); Assert.AreEqual(300000, collection[collection.Count - 1]); list = new List <int>(); for (var i = 100001; i <= 200000; i++) { list.Add(i); } collection.InsertRange(100000, list); Assert.AreEqual(300000, collection.Count); Assert.AreEqual(1, collection[0]); Assert.AreEqual(100000, collection[99999]); Assert.AreEqual(100001, collection[100000]); Assert.AreEqual(200000, collection[199999]); Assert.AreEqual(200001, collection[200000]); Assert.AreEqual(300000, collection[collection.Count - 1]); }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeBoardComboBox"/>. /// </summary> public ExchangeBoardComboBox() { IsEditable = true; var provider = ConfigManager.TryGetService<IExchangeInfoProvider>(); if (provider == null) { Boards = new ObservableCollectionEx<ExchangeBoard> { _emptyBoard }; Boards.AddRange(ExchangeBoard.EnumerateExchangeBoards().OrderBy(b => b.Code)); ConfigManager.ServiceRegistered += ConfigManagerServiceRegistered; } else FillBoards(provider); ItemsSource = Boards; DisplayMemberPath = "Code"; SelectedBoard = _emptyBoard; }
private void Window_Loaded(object sender, RoutedEventArgs e) { descriptionViewSource = ((CollectionViewSource)(this.FindResource("descriptionViewSource"))); descriptionCollection = new ObservableCollectionEx <description>(Entities.description); descriptionViewSource.Source = descriptionCollection; descriptionCollection.CollectionChanged += descriptionCollection_CollectionChanged; //groupsViewSource = ((CollectionViewSource)(this.FindResource("groupsViewSource"))); //groupsViewSource.Source = Entities.groups; // Формируем запрос для вывода его в queryResultsDataGrid queryResults = from Desc in Entities.description join Group in Entities.groups on Desc.id_desc equals Group.desc into CompGroups from CompGroup in CompGroups.DefaultIfEmpty() select new { desc_name = Desc.name, Desc.start_date, Desc.end_date, group_name = CompGroup.name, CompGroup.start_year, CompGroup.end_year }; queryResultsCollection.AddRange(queryResults); queryResultsViewSource = new CollectionViewSource(); (queryResultsViewSource as ISupportInitialize).BeginInit(); queryResultsViewSource.CollectionViewType = typeof(ListCollectionView); queryResultsViewSource.Source = queryResultsCollection; (queryResultsViewSource as ISupportInitialize).EndInit(); Binding myBinding = new Binding() { Source = queryResultsViewSource }; BindingOperations.SetBinding(queryResultsDataGrid, DataGrid.ItemsSourceProperty, myBinding); }
public SignatureWindow(string signature) { _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray()); InitializeComponent(); { var icon = new BitmapImage(); icon.BeginInit(); icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read); icon.EndInit(); if (icon.CanFreeze) { icon.Freeze(); } this.Icon = icon; } _signatureComboBox_CollectionContainer.Collection = _digitalSignatureCollection; if (_digitalSignatureCollection.Count > 0) { _signatureComboBox.SelectedIndex = 1; } if (signature != null) { for (int index = 0; index < Settings.Instance.Global_DigitalSignatures.Count; index++) { if (Settings.Instance.Global_DigitalSignatures[index].ToString() == signature) { _signatureComboBox.SelectedIndex = index + 1; break; } } } }
public void InterpolateSpline(double resolution = 0.25, double weight = 1) { if (Points.Count < 3) { return; } if (_Spline == null) { _Spline = new BezierSpline(Points.Select(p => p.ToVector()), weight); } var finalPoints = new List <PointM>(); var splinePoints = _Spline.Interpolate(resolution); finalPoints.AddRange(splinePoints.Select(v => PointM.FromVector(v, Points[0].Unit))); if (finalPoints.Count > 1) { _Points.Clear(); _Points.AddRange(finalPoints); } }
public UploadWindow(string filePath, bool isShare, AmoebaManager amoebaManager) { _amoebaManager = amoebaManager; _filePath = filePath; _isShare = isShare; _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray()); InitializeComponent(); _nameTextBox.MaxLength = Seed.MaxNameLength; _keywordsComboBox1.MaxLength = KeywordCollection.MaxKeywordLength; _keywordsComboBox2.MaxLength = KeywordCollection.MaxKeywordLength; _keywordsComboBox3.MaxLength = KeywordCollection.MaxKeywordLength; { var icon = new BitmapImage(); icon.BeginInit(); icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read); icon.EndInit(); if (icon.CanFreeze) { icon.Freeze(); } this.Icon = icon; } _nameTextBox.Text = System.IO.Path.GetFileName(_filePath); if (Settings.Instance.Global_UploadKeywords.Count >= 1) { _keywordsComboBox1.Text = Settings.Instance.Global_UploadKeywords[0]; } if (Settings.Instance.Global_UploadKeywords.Count >= 2) { _keywordsComboBox2.Text = Settings.Instance.Global_UploadKeywords[1]; } if (Settings.Instance.Global_UploadKeywords.Count >= 3) { _keywordsComboBox3.Text = Settings.Instance.Global_UploadKeywords[2]; } _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = "" }); _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = "" }); _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = "" }); foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = item }); } foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = item }); } foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = item }); } _signatureComboBox_CollectionContainer.Collection = _digitalSignatureCollection; if (_digitalSignatureCollection.Count > 0) { _signatureComboBox.SelectedIndex = 1; } _nameTextBox_TextChanged(null, null); }
public void AddRangeWithANullCollectionThrows() { var oc = new ObservableCollectionEx<string>(); oc.AddRange(null); }
public LayoutPolyLine(IEnumerable <PointM> points) { _Points = new ObservableCollectionEx <PointM>(); _Points.CollectionChanged += Points_CollectionChanged; _Points.AddRange(points); }
public LayoutPolyLine(IEnumerable <PointM> points, VisualElementType elementType) : base(elementType) { _Points = new ObservableCollectionEx <PointM>(); _Points.CollectionChanged += Points_CollectionChanged; _Points.AddRange(points); }
public void AddRangeWithANullCollectionThrows() { var oc = new ObservableCollectionEx <string>(); oc.AddRange(null); }
public SeedEditWindow(IEnumerable <Seed> seeds) { if (seeds.Count() == 0) { throw new ArgumentOutOfRangeException(nameof(seeds)); } _seeds = seeds.ToList(); _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray()); InitializeComponent(); _nameTextBox.MaxLength = Seed.MaxNameLength; _keywordsComboBox1.MaxLength = KeywordCollection.MaxKeywordLength; _keywordsComboBox2.MaxLength = KeywordCollection.MaxKeywordLength; _keywordsComboBox3.MaxLength = KeywordCollection.MaxKeywordLength; { var icon = new BitmapImage(); icon.BeginInit(); icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read); icon.EndInit(); if (icon.CanFreeze) { icon.Freeze(); } this.Icon = icon; } lock (_seeds[0].ThisLock) { _nameTextBox.Text = _seeds[0].Name; if (_seeds.Count != 1) { foreach (var seed in _seeds) { if (_nameTextBox.Text != seed.Name) { _nameTextBox.Text = ""; _nameTextBox.IsReadOnly = true; break; } } } lock (_seeds[0].Keywords.ThisLock) { if (_seeds[0].Keywords.Count >= 1) { _keywordsComboBox1.Text = _seeds[0].Keywords[0]; } if (_seeds[0].Keywords.Count >= 2) { _keywordsComboBox2.Text = _seeds[0].Keywords[1]; } if (_seeds[0].Keywords.Count >= 3) { _keywordsComboBox3.Text = _seeds[0].Keywords[2]; } } _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = "" }); _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = "" }); _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = "" }); foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = item }); } foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = item }); } foreach (var item in Settings.Instance.Global_SearchKeywords) { _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = item }); } } _signatureComboBox_CollectionContainer.Collection = _digitalSignatureCollection; if (_digitalSignatureCollection.Count > 0) { _signatureComboBox.SelectedIndex = 1; } _nameTextBox.TextChanged += _nameTextBox_TextChanged; _nameTextBox_TextChanged(null, null); }
public void Init() { Settings.Get("WebServer_UserName", "dave"); Settings.Get("WebServer_Password", "dave"); // Load up on-demand plugins, like WebServer Loaders.AddRange(Plugin.Load <ILoader>().ToArray()); foreach (var loader in Loaders) { loader.Load(); } // Load up device discovery buses. (DirectShow, IPCam-Foscam, Unity) Buses.AddRange(Plugin.Load <IDeviceBus>().ToArray()); foreach (var b in Buses) { Trace.WriteLine("Searching bus: " + b.Name); b.Discovered += (dev, bus) => { Trace.WriteLine(string.Format("Core Found: [{0}:{1}]", bus, dev)); var vdev = dev as IVideoDevice; if (vdev != null) { // TODO: add timestamp, etc. vdev.FilterFrame += (f) => { return(f); }; } Devices.Add(dev); DeviceAdded(dev, bus); }; b.Discover(); IDeviceBusAltDiscovery altBus = b as IDeviceBusAltDiscovery; if (altBus != null) { if (b.Name == "Foscam") { altBus.Create(new Dictionary <string, string> { { "Host", "davux2.mooo.com:89" }, { "Display Name", "Dave-Seattle" }, { "Camera Version", "FI8918W" }, }); altBus.Create(new Dictionary <string, string> { { "Host", "davux.mooo.com:89" }, { "Display Name", "Dave-Home" }, { "Camera Version", "FI8918W" }, }); } else if (b.Name == "Mjpeg") { altBus.Create(new Dictionary <string, string> { { "Url", "http://192.168.0.133:8080/videofeed" }, { "Display Name", "Wall Slate" }, }); } else if (b.Name == "JpegUdp") { altBus.Create(new Dictionary <string, string> { { "Rotate", "90" }, { "Port", "11000" }, { "Display Name", "UDP Broadcast Video" }, }); } } } }