Beispiel #1
0
        //adds or removes items from the list
        private static void AddRemoveItems(RatingSelector selector, int diff, bool decreaseRange)
        {
            if (decreaseRange)
            {
                //remove items that are not needed
                for (int i = 0; i < diff; i++)
                {
                    //check if there are any items to delete
                    if (selector.ratingItems.Count == 0)
                    {
                        break;
                    }
                    selector.ratingItems.RemoveAt(0);
                }
            }
            else
            {
                diff = -diff;//since this would be a negative number
                for (int i = 0; i < diff; i++)
                {
                    selector.ratingItems.Insert(0, selector.CreateItem(i, false));
                }
            }

            //re arrange items
            selector.ReAssignRateValue();
            selector.SelectItems();
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\RatingSelectorTest.xaml"
                ((TestApplication.RatingSelectorTest)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.rating = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
                return;

            case 3:
                this.rating2 = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
                return;

            case 4:
                this.rating3 = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #3
0
        //validate the selected rating
        static object ForceRatingSelected(DependencyObject sender, object value)
        {
            RatingSelector selector = (RatingSelector)sender;
            int            val      = (int)value;

            val = Math.Max(selector.MinRating, val);
            val = Math.Min(selector.MaxRating, val);
            return(val);
        }
Beispiel #4
0
        //handler for the property changed of the ratingselected prop
        static void RatingSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RatingSelector selector = (RatingSelector)sender;

            if (!selector.IsInitialized)
            {
                return;
            }
            selector.SelectItems();
        }
Beispiel #5
0
        //handler max rating selected
        static void MaxRatingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RatingSelector selector = (RatingSelector)sender;

            if (!selector.IsInitialized)
            {
                return;
            }
            int  oldValue      = (int)e.OldValue;
            int  newValue      = (int)e.NewValue;
            int  diff          = oldValue - newValue;
            bool decreaseRange = diff > 0;

            AddRemoveItems(selector, diff, decreaseRange);
            selector.CoerceValue(RatingSelector.MinRatingProperty);
        }
Beispiel #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parentSelector">The owner of the item</param>
        public RatingSelectorItem(RatingSelector parentSelector)
        {
            this.parentSelector = parentSelector;
            //handle the parentSelector
            this.parentSelector.RateItemMouseOver += new EventHandler <RateItemMouseOverEventArgs>(ParentSelectorRateItemMouseOver);

            //when the item is mouse over raise the event so that the other rate items know about it
            MouseEnter += delegate
            {
                parentSelector.NotifyItemMouseOver(RateValue, false);
            };

            MouseLeave += delegate
            {
                parentSelector.NotifyItemMouseOver(RateValue, true);
            };
        }
Beispiel #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parentSelector">The owner of the item</param>
        public RatingSelectorItem(RatingSelector parentSelector)
        {
            this.parentSelector = parentSelector;
            //handle the parentSelector
            this.parentSelector.RateItemMouseOver += new EventHandler<RateItemMouseOverEventArgs>(ParentSelectorRateItemMouseOver);

            //when the item is mouse over raise the event so that the other rate items know about it
            MouseEnter += delegate
            {
                parentSelector.NotifyItemMouseOver(RateValue, false);
            };

            MouseLeave += delegate
            {
                parentSelector.NotifyItemMouseOver(RateValue, true);
            };
        }
Beispiel #8
0
        //adds or removes items from the list
        private static void AddRemoveItems(RatingSelector selector, int diff, bool decreaseRange)
        {
            if (decreaseRange)
            {
                //remove items that are not needed
                for (int i = 0; i < diff; i++)
                {
                    //check if there are any items to delete
                    if (selector.ratingItems.Count == 0)
                        break;
                    selector.ratingItems.RemoveAt(0);
                }
            }
            else
            {
                diff = -diff;//since this would be a negative number
                for (int i = 0; i < diff; i++)
                    selector.ratingItems.Insert(0, selector.CreateItem(i, false));
            }

            //re arrange items
            selector.ReAssignRateValue();
            selector.SelectItems();
        }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 5 "..\..\RatingSelectorTest.xaml"
     ((TestApplication.RatingSelectorTest)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
     
     #line default
     #line hidden
     return;
     case 2:
     this.rating = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
     return;
     case 3:
     this.rating2 = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
     return;
     case 4:
     this.rating3 = ((AC.AvalonControlsLibrary.Controls.RatingSelector)(target));
     return;
     }
     this._contentLoaded = true;
 }