public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
            {
                this.owner = owner;

                if (!owner.IsReadyToDrawMarkers())
                {
                    return;
                }

                int newStartingIndex = e.NewStartingIndex;

                if (newStartingIndex == owner.lastIndex)
                {
                    AddNewItems(e);
                }
                else if (owner.startIndex <= newStartingIndex && newStartingIndex <= owner.lastIndex)
                {
                    foreach (UIElement child in owner.CurrentItemsPanel.Children)
                    {
                        var index = GetIndex(child);
                        if (index >= newStartingIndex)
                        {
                            SetIndex(child, index + 1);
                        }
                    }
                    AddNewItems(e);
                }
            }
            public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
            {
                int oldStartingIndex = e.OldStartingIndex;

                int oldEndIndex = oldStartingIndex + e.OldItems.Count;

                var children = new UIElement[owner.CurrentItemsPanel.Children.Count];

                owner.CurrentItemsPanel.Children.CopyTo(children, 0);
                foreach (UIElement item in children)
                {
                    var index = GetIndex(item);
                    if (oldStartingIndex <= index && index < oldEndIndex)
                    {
                        owner.CurrentItemsPanel.Children.Remove(item);
                    }
                }

                int oldCount = e.OldItems.Count;

                foreach (UIElement item in owner.CurrentItemsPanel.Children)
                {
                    var index = GetIndex(item);
                    if (index >= oldEndIndex)
                    {
                        SetIndex(item, index - oldCount);
                    }
                }
            }
Example #3
0
        private static void OnMarkerBuilderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DevMarkerChart owner = (DevMarkerChart)d;

            owner.OnMarkerGeneratorChanged((MarkerGenerator)e.OldValue, (MarkerGenerator)e.NewValue);

            owner.MarkerBuilderChanged.Raise(owner, e.OldValue, e.NewValue);
        }
            public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
            {
                //var markerGenerator = owner.markerGenerator;
                //if (markerGenerator != null)
                //{
                //    foreach (FrameworkElement marker in owner.CurrentItemsPanel.Children)
                //    {
                //        owner.RemoveCommonBindings(marker);
                //        markerGenerator.Release(marker);
                //    }
                //}

                //owner.CurrentItemsPanel.Children.Clear();
                owner.DrawAllMarkers(true);
            }
			public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
			{
				//var markerGenerator = owner.markerGenerator;
				//if (markerGenerator != null)
				//{
				//    foreach (FrameworkElement marker in owner.CurrentItemsPanel.Children)
				//    {
				//        owner.RemoveCommonBindings(marker);
				//        markerGenerator.Release(marker);
				//    }
				//}

				//owner.CurrentItemsPanel.Children.Clear();
				owner.DrawAllMarkers(true);
			}
		public void TestAddAndRemoveItems()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();

			DevMarkerChart chart = new DevMarkerChart();
			chart.MarkerBuilder = new EllipseMarker();

			plotter.Children.Add(chart);

			ObservableCollection<Point> source = new ObservableCollection<Point>();
			chart.ItemsSource = source;

			const int count = 10;

			// stage 1
			for (int i = 0; i < count; i++)
			{
				source.Add(new Point());
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			for (int i = count - 1; i >= 0; i--)
			{
				source.RemoveAt(i);
				Assert.AreEqual(source.Count, chart.Items.Count);
			}


			// stage 2
			for (int i = 0; i < count; i++)
			{
				source.Add(new Point());
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			Random rnd = new Random();
			for (int i = count - 1; i >= 0; i--)
			{
				int index = rnd.Next(0, source.Count - 1);
				source.RemoveAt(index);
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			// todo check that all items are visible
		}
			public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
			{
				this.owner = owner;

				if (!owner.IsReadyToDrawMarkers()) return;

				int newStartingIndex = e.NewStartingIndex;
				if (newStartingIndex == owner.lastIndex)
				{
					AddNewItems(e);
				}
				else if (owner.startIndex <= newStartingIndex && newStartingIndex <= owner.lastIndex)
				{
					foreach (UIElement child in owner.CurrentItemsPanel.Children)
					{
						var index = GetIndex(child);
						if (index >= newStartingIndex)
						{
							SetIndex(child, index + 1);
						}
					}
					AddNewItems(e);
				}
			}
Example #8
0
 private static void OnMarkerBuilderTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     DevMarkerChart owner = (DevMarkerChart)d;
     // owner.MarkerBuilder = new TemplateMarkerGenerator((DataTemplate)e.NewValue);
 }
Example #9
0
        private static void OnMarkerTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DevMarkerChart owner = (DevMarkerChart)d;

            owner.OnMarkerTemplateChanged((DataTemplate)e.NewValue, (DataTemplate)e.OldValue);
        }
 public abstract void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e);
			public abstract void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e);
			public override void Work(DevMarkerChart owner, NotifyCollectionChangedEventArgs e)
			{
				int oldStartingIndex = e.OldStartingIndex;

				int oldEndIndex = oldStartingIndex + e.OldItems.Count;

				var children = new UIElement[owner.CurrentItemsPanel.Children.Count];
				owner.CurrentItemsPanel.Children.CopyTo(children, 0);
				foreach (UIElement item in children)
				{
					var index = GetIndex(item);
					if (oldStartingIndex <= index && index < oldEndIndex)
					{
						owner.CurrentItemsPanel.Children.Remove(item);
					}
				}

				int oldCount = e.OldItems.Count;
				foreach (UIElement item in owner.CurrentItemsPanel.Children)
				{
					var index = GetIndex(item);
					if (index >= oldEndIndex)
					{
						SetIndex(item, index - oldCount);
					}
				}
			}