internal void CleanContainers() { RadBook radBook = ItemsControl.GetItemsOwner((DependencyObject)this) as RadBook; if (radBook == null) { return; } int count = radBook.Items.Count; IItemContainerGenerator containerGenerator1 = this.ItemContainerGenerator; int num = this.startingIndex + Math.Min(this.GenerateSpan, count - this.startingIndex); ItemContainerGenerator containerGenerator2 = radBook.ItemContainerGenerator; for (int index = 0; index < this.Children.Count; ++index) { UIElement uiElement = this.Children[index]; int itemIndex = containerGenerator2.IndexFromContainer((DependencyObject)uiElement); if (itemIndex != -1 && (itemIndex < this.startingIndex || itemIndex >= num) && !this.IndexCollection.Contains(itemIndex)) { GeneratorPosition position = containerGenerator1.GeneratorPositionFromIndex(itemIndex); containerGenerator1.Remove(position, 1); this.RemoveInternalChildRange(index, 1); --index; } } }
/// <summary> /// Requests a page move to the page at the specified index. /// /// </summary> /// <param name="pageIndex">The index of the page to move to.</param> public bool MoveToPage(int pageIndex) { int rightPageIndex = this.owner.FirstPagePosition != PagePosition.Left ? pageIndex * 2 : pageIndex * 2 + 1; this.owner.RightPageIndex = rightPageIndex; this.OnPageChanging(RadBook.ConvertPageToSheetIndex(rightPageIndex, this.owner.FirstPagePosition)); return(true); }
/// <summary> /// Override for Measure. /// /// </summary> /// <param name="availableSize"/> /// <returns/> protected override Size MeasureOverride(Size availableSize) { this.halfSize = new Size(availableSize.Width / 2.0, availableSize.Height); this.pageMaxDesiredSize = new Size(); RadBook radBook = ItemsControl.GetItemsOwner((DependencyObject)this) as RadBook; if (radBook == null) { return(availableSize); } UIElementCollection children = this.Children; int count = radBook.Items.Count; IItemContainerGenerator containerGenerator = this.ItemContainerGenerator; if (radBook.IsVirtualizing) { int itemsCount = Math.Min(this.GenerateSpan, count - this.startingIndex); this.PrepareItems(containerGenerator, this.startingIndex, itemsCount); foreach (int itemIndex in (IEnumerable <int>) this.IndexCollection) { using (containerGenerator.StartAt(containerGenerator.GeneratorPositionFromIndex(itemIndex), GeneratorDirection.Forward, true)) { bool isNewlyRealized; FrameworkElement frameworkElement = containerGenerator.GenerateNext(out isNewlyRealized) as FrameworkElement; if (frameworkElement != null) { if (isNewlyRealized) { this.AddInternalChild((UIElement)frameworkElement); containerGenerator.PrepareItemContainer((DependencyObject)frameworkElement); } frameworkElement.Measure(this.halfSize); this.pageMaxDesiredSize = new Size() { Height = Math.Max(this.pageMaxDesiredSize.Height, frameworkElement.DesiredSize.Height), Width = Math.Max(this.pageMaxDesiredSize.Width, frameworkElement.DesiredSize.Width) }; } } } this.CleanContainers(); } else { this.PrepareItems(containerGenerator, 0, count); } double val1 = this.pageMaxDesiredSize.Width * 2.0; return(new Size() { Width = double.IsInfinity(availableSize.Width) ? val1 : Math.Min(val1, availableSize.Width), Height = double.IsInfinity(availableSize.Height) ? this.pageMaxDesiredSize.Height : Math.Min(this.pageMaxDesiredSize.Height, availableSize.Height) }); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { RadBookItem page = container as RadBookItem; // we need an instance of the book so that we can determine the whether the current page is the last page. RadBook book = System.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(container) as RadBook; // Using the index property, we can determine whether the page is last page or it is one of the inner left pages. if (page.Index == book.Items.Count - 1) { return(this.BackCoverTemplate); } else { return(this.LeftPageTemplate); } }
public static bool MouseWithinFoldAreas(Point mousePoint, RadBook book) { double actualWidth = book.ActualWidth; double num = actualWidth / 2.0; double actualHeight = book.ActualHeight; Size foldSize = book.FoldSize; if (mousePoint.X < num) { return(FoldHelper.MouseWithinTopLeftFoldArea(mousePoint, foldSize) || FoldHelper.MouseWithinBottomLeftFoldArea(mousePoint, foldSize, actualHeight)); } else { return(FoldHelper.MouseWithinTopRightFoldArea(mousePoint, foldSize, actualWidth) || FoldHelper.MouseWithinBottomRightFoldArea(mousePoint, foldSize, actualWidth, actualHeight)); } }
public static FoldPosition GetQuadrant(Point mousePoint, RadBook book) { double actualWidth = book.ActualWidth; double actualHeight = book.ActualHeight; double num1 = actualWidth / 2.0; double num2 = book.ActualHeight / 2.0; if (mousePoint.X < num1 && mousePoint.Y < num2) { return(FoldPosition.TopLeft); } if (mousePoint.X < num1 && mousePoint.Y >= num2) { return(FoldPosition.BottomLeft); } return(mousePoint.X >= num1 && mousePoint.Y < num2 ? FoldPosition.TopRight : FoldPosition.BottomRight); }
public PageTurner(RadBook book) { PageTurner pageTurner = this; CircleEase circleEase1 = new CircleEase(); circleEase1.EasingMode = EasingMode.EaseOut; CircleEase circleEase2 = circleEase1; pageTurner.easingFunction = (IEasingFunction)circleEase2; this.timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1.0) }; // ISSUE: explicit constructor call // base.\u002Ector(); this.book = book; this.IsAvailable = true; this.timer.Tick += new EventHandler(this.Timer_Tick); }
public PageTurner(RadBook book, IEasingFunction easingFunction) : this(book) { this.easingFunction = easingFunction; }
/// <summary> /// Initializes a new instance of the <see cref="T:Telerik.Windows.Controls.Book.BookPagedCollectionView"/> class. /// /// </summary> /// <param name="owner">The owner.</param> public BookPagedCollectionView(RadBook owner) { this.owner = owner; this.owner.PageChanged += new ExtendedRoutedEventHandler(this.Book_PageChanged); this.owner.ItemsCountChanged += new EventHandler <EventArgs>(this.Book_ItemsCountChanged); }