Browse Source

Removed Thingamybob.

Steven Kirk 9 years ago
parent
commit
f12435731b

+ 0 - 2
src/Avalonia.Controls/Avalonia.Controls.csproj

@@ -72,7 +72,6 @@
     <Compile Include="Presenters\ItemsPresenterBase.cs" />
     <Compile Include="Presenters\ItemVirtualizerNone.cs" />
     <Compile Include="Presenters\ItemVirtualizerSimple.cs" />
-    <Compile Include="Presenters\ThingamybobPresenter.cs" />
     <Compile Include="Presenters\ItemVirtualizer.cs" />
     <Compile Include="Primitives\HeaderedSelectingControl.cs" />
     <Compile Include="Primitives\IScrollable.cs" />
@@ -167,7 +166,6 @@
     <Compile Include="Templates\ITemplate`1.cs" />
     <Compile Include="Templates\ITreeDataTemplate.cs" />
     <Compile Include="Templates\FuncTreeDataTemplate.cs" />
-    <Compile Include="Thingamybob.cs" />
     <Compile Include="ToolTip.cs" />
     <Compile Include="UserControl.cs" />
     <Compile Include="Templates\TemplateExtensions.cs" />

+ 0 - 114
src/Avalonia.Controls/Presenters/ThingamybobPresenter.cs

@@ -1,114 +0,0 @@
-using System;
-using Avalonia.Controls.Primitives;
-using Avalonia.Media;
-
-namespace Avalonia.Controls.Presenters
-{
-    public class ThingamybobPresenter : Decorator, IItemsPresenter, IScrollable
-    {
-        private IVirtualizingPanel _panel;
-        private int _firstIndex;
-        private int _lastIndex;
-
-        public override void ApplyTemplate()
-        {
-            if (_panel == null)
-            {
-                _panel = new VirtualizingStackPanel();
-                Child = _panel;
-                CheckPanel();
-            }
-        }
-
-        public IPanel Panel => _panel;
-
-        bool IScrollable.IsLogicalScrollEnabled => true;
-        Action IScrollable.InvalidateScroll { get; set; }
-
-        Size IScrollable.Extent => new Size(1, 100 * AverageItemSize );
-
-        Vector IScrollable.Offset
-        {
-            get
-            {
-                return new Vector(0, (_firstIndex * AverageItemSize) + (_panel?.PixelOffset ?? 0));
-            }
-
-            set
-            {
-                var count = _lastIndex - _firstIndex;
-                var firstIndex = (int)(value.Y / AverageItemSize);
-                var firstIndexChanged = _firstIndex != firstIndex;
-                _firstIndex = firstIndex;
-                _lastIndex = _firstIndex + count;
-                _panel.PixelOffset = value.Y % AverageItemSize;
-
-                if (firstIndexChanged)
-                {
-                    Renumber();
-                }
-            }
-        }
-
-        Size IScrollable.Viewport => new Size(1, _panel?.Bounds.Height ?? 0);
-        Size IScrollable.ScrollSize => new Size(0, 1);
-        Size IScrollable.PageScrollSize => new Size(0, 1);
-
-        private double AverageItemSize => _panel?.AverageItemSize ?? 1;
-
-        protected override Size ArrangeOverride(Size finalSize)
-        {
-            var result = base.ArrangeOverride(finalSize);
-            CreateItems();
-            ((IScrollable)this).InvalidateScroll();
-            return result;
-        }
-
-        private void CreateItems()
-        {
-            var randomColor = Color.FromUInt32(
-                (uint)(0xff000000 + new Random().Next(0xffffff)));
-
-            while (!_panel.IsFull)
-            {
-                _panel.Children.Add(new TextBlock
-                {
-                    Text = "Item " + ++_lastIndex,
-                    Background = new SolidColorBrush(randomColor),
-                });
-            }
-        }
-
-        private void RemoveItems()
-        {
-            var remove = _panel.OverflowCount;
-
-            _panel.Children.RemoveRange(
-                _panel.Children.Count - remove,
-                _panel.OverflowCount);
-            _lastIndex -= remove;
-        }
-
-        private void Renumber()
-        {
-            var index = _firstIndex;
-
-            foreach (TextBlock child in _panel.Children)
-            {
-                child.Text = "Item " + ++index;
-            }
-        }
-
-        private void CheckPanel()
-        {
-            if (!_panel.IsFull)
-            {
-                CreateItems();
-            }
-            else if (_panel.OverflowCount > 1)
-            {
-                RemoveItems();
-            }
-        }
-    }
-}

+ 0 - 25
src/Avalonia.Controls/Thingamybob.cs

@@ -1,25 +0,0 @@
-using Avalonia.Media;
-using System;
-using Avalonia.Controls.Primitives;
-using Avalonia.Controls.Presenters;
-
-namespace Avalonia.Controls
-{
-    public class Thingamybob : Decorator
-    {
-        private ScrollViewer _scrollViewer;
-        private ThingamybobPresenter _presenter;
-
-        public override void ApplyTemplate()
-        {
-            if (Child == null)
-            {
-                _scrollViewer = new ScrollViewer();
-                _presenter = new ThingamybobPresenter();
-                _scrollViewer.Content = _presenter;
-
-                Child = _scrollViewer;
-            }
-        }
-    }
-}