/// <summary> /// Initiates swap between the current item and the one whose index is supplied. /// </summary> /// <param name="index">the index of the item in the <see cref="Items"/> collection. The index of the home element is -1.</param> /// <returns>true on successful swap</returns> public bool Goto(int index) { if (index < -2 || index >= this.Items.Count) { return(false); } //if (timer.Enabled) // timer.Stop(); if (currentIndex == index) { return(true); } BeginRotateEventArgs ea = new BeginRotateEventArgs(currentIndex, index); this.OnBeginRotate(this, ea); if (ea.Cancel) { return(true); } RadItem itemToHide = GetItem(currentIndex); RadItem itemToShow = GetItem(ea.To); currentIndex = index; SwapItems(itemToHide, itemToShow); return(true); }
private bool SwapItems(int to) { if (currentIndex == to) { timer.Stop(); return(false); } BeginRotateEventArgs ea = new BeginRotateEventArgs(currentIndex, to); this.OnBeginRotate(this, ea); if (ea.Cancel) { return(false); } if (ea.To < -1 || ea.To >= items.Count) { throw new ArgumentOutOfRangeException("ea.TO", "Should be a valid index in the Items collection, or -1 for default item"); } RadItem fadeOutItem = GetItem(currentIndex); RadItem fadeInItem = GetItem(ea.To); SwapItems(fadeOutItem, fadeInItem); currentIndex = ea.To; return(true); }
protected virtual void OnBeginRotate(object sender, BeginRotateEventArgs e) { BeginRotateEventHandler handler = (BeginRotateEventHandler)this.Events[BeginRotateEventKey]; if (handler != null) { handler(sender, e); } }
protected virtual void OnBeginRotate(object sender, BeginRotateEventArgs e) { BeginRotateEventHandler rotateEventHandler = (BeginRotateEventHandler)this.Events[RadRotatorItem.BeginRotateEventKey]; if (rotateEventHandler == null) { return; } rotateEventHandler(sender, e); }
private bool SwapItems(int to) { if (this.currentIndex == to) { this.timer.Stop(); return(false); } BeginRotateEventArgs e = new BeginRotateEventArgs(this.currentIndex, to); this.OnBeginRotate((object)this, e); if (e.Cancel) { return(false); } if (e.To < -1 || e.To >= this.items.Count) { throw new ArgumentOutOfRangeException("ea.TO", "Should be a valid index in the Items collection, or -1 for default item"); } this.SwapItems(this.GetItem(this.currentIndex), this.GetItem(e.To)); this.currentIndex = e.To; return(true); }
public bool Goto(int index) { if (index < -2 || index >= this.Items.Count) { return(false); } if (this.currentIndex == index) { return(true); } BeginRotateEventArgs e = new BeginRotateEventArgs(this.currentIndex, index); this.OnBeginRotate((object)this, e); if (e.Cancel) { return(true); } RadItem itemToHide = this.GetItem(this.currentIndex); RadItem itemToShow = this.GetItem(e.To); this.currentIndex = index; this.SwapItems(itemToHide, itemToShow); return(true); }