Beispiel #1
0
        /// <summary>
        /// ReAssign angle of all items
        /// </summary>
        //private void ReAssignAngle()
        //{
        //    if (CarouselCanvas != null)
        //    {
        //        int count = CarouselCanvas.Children.Count;
        //        // Re calc the angle
        //        double perAngle = _2PI / count;
        //        for(int i=0;i<count;i++)
        //        {
        //            (CarouselCanvas.Children[i] as CarouselItem).Angle = i * perAngle;
        //        }
        //    }
        //}

        // Fire the SelectedItemChanged event
        void OnSelectedItemChanged(ItemSource item)
        {
            if (SelectedItemChanged != null)
            {
                SelectedItemChangedEventArgs e = new SelectedItemChangedEventArgs(item);
                SelectedItemChanged(this, e);
            }
        }
Beispiel #2
0
 // User click the item with left mouse button
 void item_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (SelectedItemViewer != null)
     {
         CarouselItem item   = sender as CarouselItem;
         ItemSource   source = item.Tag as ItemSource;
         SelectedItemViewer.Source      = source.ImageSource;
         SelectedItemViewer.Title       = source.Title;
         SelectedItemViewer.NavigateUri = source.NavigateUri;
         OnSelectedItemChanged(source);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Place a item to carousel canvas.
        /// </summary>
        /// <param name="item">The item will be placed.</param>
        /// <returns>The <see cref="CarouselItem"/> just placed.</returns>
        private CarouselItem PlaceItem(ItemSource item)
        {
            CarouselItem cItem = new CarouselItem();

            cItem.Width  = ItemWidth;
            cItem.Height = ItemHeight;
            cItem.Source = item.ImageSource;
            cItem.Tag    = item;

            // Attach the handle
            cItem.MouseLeftButtonDown += new MouseButtonEventHandler(item_MouseLeftButtonDown);

            // Add item to carousel canvas
            CarouselCanvas.Children.Add(cItem);

            return(cItem);
        }
Beispiel #4
0
 /// <summary>
 /// Initialize a new instance of <see cref="SelectedItemChangedEventArgs"/>
 /// class supplies the selected item.
 /// </summary>
 /// <param name="selectedItem">The selected <see cref="ItemSource"/> item.</param>
 public SelectedItemChangedEventArgs(ItemSource selectedItem)
 {
     this.SelectedItem = selectedItem;
 }