Ejemplo n.º 1
0
        /// <summary>
        /// Handles the current level value change.
        /// </summary>
        /// <param name="oldValue">Old value.</param>
        /// <param name="newValue">New value.</param>
        private void OnCurrentLevelChange(int oldValue, int newValue)
        {
            if (oldValue >= 0 && oldValue <= this.tickContainer.Children.Count && newValue > 0 && newValue <= this.tickContainer.Children.Count)
            {
                LevelOfDetailTick oldTick = null;
                LevelOfDetailTick newTick = null;

                if (oldValue > 0)
                {
                    oldTick = this.tickContainer.Children[oldValue - 1] as LevelOfDetailTick;
                    if (oldTick != null)
                    {
                        oldTick.Selected = false;
                    }
                }

                if (newValue > 0)
                {
                    newTick = this.tickContainer.Children[newValue - 1] as LevelOfDetailTick;
                    if (newTick != null)
                    {
                        newTick.Selected = true;
                    }
                }

                this.RaiseLevelOfDetailChangeEvent(oldValue, newValue);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the property changed event of the selected property.
        /// </summary>
        /// <param name="d">DependencyObject whose selected property changed.</param>
        /// <param name="e">Event args containing instance data.</param>
        private static void OnSelectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LevelOfDetailTick tick = d as LevelOfDetailTick;

            if (tick != null && e.OldValue != e.NewValue)
            {
                tick.TransitionState();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the mouse left button up event of the tick.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event args containing instance data.</param>
        private void Tick_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            LevelOfDetailTick tick = sender as LevelOfDetailTick;

            if (tick != null)
            {
                int tickIndex = Convert.ToInt32(tick.Tag, CultureInfo.CurrentCulture);
                this.CurrentLevel = tickIndex;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds ticks to Tick container.
        /// </summary>
        private void AddTicks()
        {
            for (int tickIndex = 0; tickIndex < this.NumberOfLevels; tickIndex++)
            {
                if (this.tickContainer.Resources.Contains(TickTemplateName))
                {
                    LevelOfDetailTick tick = (this.tickContainer.Resources[TickTemplateName] as DataTemplate).LoadContent() as LevelOfDetailTick;

                    if (tick != null)
                    {
                        tick.Tag = tickIndex + 1;
                        if (tickIndex + 1 == this.CurrentLevel)
                        {
                            tick.Selected = true;
                        }

                        tick.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.Tick_MouseLeftButtonUp);
                        this.tickContainer.Children.Add(tick);
                    }
                }
            }
        }