コード例 #1
0
        void OnItemSizeChanged(object sender, SizeChangedEventArgs e)
        {
            CoverFlowItem item  = sender as CoverFlowItem;
            int           index = items.IndexOf(item);

            LayoutChild(item, index);
        }
コード例 #2
0
        protected void LayoutChild(CoverFlowItem item, int index)
        {
            double m = ItemsPresenter.ActualWidth / 2;

            int    b  = index - SelectedIndex;
            double mu = 0;

            if (b < 0)
            {
                mu = -1;
            }
            else if (b > 0)
            {
                mu = 1;
            }
            double x = (m + ((double)b * l + (k * mu))) - (item.ActualWidth / 2);

            double s = mu == 0 ? 1 : Scale;

            int zindex = items.Count - Math.Abs(b);

            if (((x + item.ActualWidth) < 0 || x > ItemsPresenter.ActualWidth) &&
                ((item.X + item.ActualWidth) < 0 || item.X > ItemsPresenter.ActualWidth) &&
                !((x + item.ActualWidth) < 0 && item.X > ItemsPresenter.ActualWidth) &&
                !((item.X + item.ActualWidth) < 0 && x > ItemsPresenter.ActualWidth))
            {
                item.SetValues(x, zindex, r * mu, z * Math.Abs(mu), s, duration, EasingFunction, false);
            }
            else
            {
                item.SetValues(x, zindex, r * mu, z * Math.Abs(mu), s, duration, EasingFunction, true);
            }
        }
コード例 #3
0
        protected override DependencyObject GetContainerForItemOverride()
        {
            CoverFlowItem item = new CoverFlowItem();

            item.Height = ItemsPresenter.ActualHeight;
            return(item);
        }
コード例 #4
0
        public void UpdatePositions(object value)
        {
            CoverFlowItem item = GetItemContainerForObject(value);

            if (item != null)
            {
                int index = items.IndexOf(item);
                LayoutChild(item, index);
            }
        }
コード例 #5
0
        protected CoverFlowItem GetItemContainerForObject(object value)
        {
            CoverFlowItem item = value as CoverFlowItem;

            if (item == null)
            {
                this.ObjectToItemContainer.TryGetValue(value, out item);
            }
            return(item);
        }
コード例 #6
0
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            base.ClearContainerForItemOverride(element, item);
            CoverFlowItem item2 = element as CoverFlowItem;

            if (item2 != item)
            {
                this.ObjectToItemContainer.Remove(item);
            }

            items.Remove(item2);
        }
コード例 #7
0
        void OnItemSelected(object sender, EventArgs e)
        {
            CoverFlowItem item = sender as CoverFlowItem;

            if (item != null)
            {
                int index = items.IndexOf(item);

                if (index == this.SelectedIndex && ItemClick != null)
                {
                    ItemClick(this, null);
                }
                else if (index >= 0)
                {
                    IndexSelected(index, true);
                }
            }
        }
コード例 #8
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Size size = base.ArrangeOverride(finalSize);
            RectangleGeometry visibleArea = new RectangleGeometry();
            Rect clip = new Rect(0, 0, ItemsPresenter.ActualWidth, ItemsPresenter.ActualHeight);

            foreach (CoverFlowItem item in items)
            {
                item.Height = ItemsPresenter.ActualHeight;
            }

            visibleArea.Rect    = clip;
            ItemsPresenter.Clip = visibleArea;

            double m = ItemsPresenter.ActualWidth / 2;

            for (int index = 0; index < items.Count; index++)
            {
                CoverFlowItem item = items[index];
                int           b    = index - SelectedIndex;
                double        mu   = 0;
                if (b < 0)
                {
                    mu = -1;
                }
                else if (b > 0)
                {
                    mu = 1;
                }
                double x = (m + ((double)b * l + (k * mu))) - (item.ActualWidth / 2);

                double s = mu == 0 ? 1 : Scale;

                int zindex = items.Count - Math.Abs(b);

                item.X         = x;
                item.YRotation = r * mu;
                item.ZOffset   = z * Math.Abs(mu);
                item.Scale     = s;
            }

            return(size);
        }
コード例 #9
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            CoverFlowItem item2 = element as CoverFlowItem;

            if (item2 != item)
            {
                this.ObjectToItemContainer[item] = item2;
            }

            if (!items.Contains(item2))
            {
                items.Add(item2);
                item2.ItemSelected += new EventHandler(OnItemSelected);
                item2.SizeChanged  += new SizeChangedEventHandler(OnItemSizeChanged);
            }

            if (items.Count == 1)
            {
                IndexSelected(0, false, false);
            }
        }