protected void Load(VirtualizableState newState) { this._view.Height = this.FixedHeight; if (this.CurrentState == VirtualizableState.Unloaded) { ++VirtualizableItemBase._loadedCounter; int num = VirtualizableItemBase._loadedCounter % 10; this.GenerateChildren(); foreach (UIElement child in this.Children) { this._view.Children.Add(child); } foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(newState); this._view.Children.Add((UIElement)virtualizableChild.View); } this.CurrentState = VirtualizableState.LoadedPartially; } if (newState != VirtualizableState.LoadedFully) { return; } this.LoadFullyNonVirtualizableItems(); foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(VirtualizableState.LoadedFully); this.CurrentState = VirtualizableState.LoadedFully; } }
protected void Load(VirtualizableState newState) { ((FrameworkElement)this._view).Height = this.FixedHeight; if (this.CurrentState == VirtualizableState.Unloaded) { ++VirtualizableItemBase._loadedCounter; int num = VirtualizableItemBase._loadedCounter % 10; this.GenerateChildren(); using (List <FrameworkElement> .Enumerator enumerator = this.Children.GetEnumerator()) { while (enumerator.MoveNext()) { ((PresentationFrameworkCollection <UIElement>)((Panel)this._view).Children).Add((UIElement)enumerator.Current); } } foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(newState); ((PresentationFrameworkCollection <UIElement>)((Panel)this._view).Children).Add((UIElement)virtualizableChild.View); } this.CurrentState = VirtualizableState.LoadedPartially; } if (newState != VirtualizableState.LoadedFully) { return; } this.LoadFullyNonVirtualizableItems(); foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(VirtualizableState.LoadedFully); this.CurrentState = VirtualizableState.LoadedFully; } }
private void SetLoadedBounds(int lowerBoundInd, int upperBoundInd, VirtualizableState desiredState, bool bypassUnload = false) { Segment segment = new Segment(lowerBoundInd, upperBoundInd); Segment thisMinusOther1; Segment thisMinusOther2; Segment intersection; Segment otherMinusThis1; Segment otherMinusThis2; segment.CompareToSegment(this._loadedSegment, out thisMinusOther1, out thisMinusOther2, out intersection, out otherMinusThis1, out otherMinusThis2); this.Log(string.Format("LoadedSegment:{0}, NewSegment:{1}, NewMinusLoaded1:{2}, NewMinusLoaded2:{3}, loadedMinusNew1:{4}, loadedMinusNew2:{5}", (object)this._loadedSegment, (object)segment, (object)thisMinusOther1, (object)thisMinusOther2, (object)otherMinusThis1, (object)otherMinusThis2)); if (desiredState == VirtualizableState.LoadedPartially || this.OnlyPartialLoad) { this.LoadItemsInSegment(thisMinusOther1, VirtualizableState.LoadedPartially); this.LoadItemsInSegment(thisMinusOther2, VirtualizableState.LoadedPartially); } else if (desiredState == VirtualizableState.LoadedFully) { this.LoadItemsInSegment(segment, VirtualizableState.LoadedFully); } if (!bypassUnload) { this.UnloadItemsInSegment(otherMinusThis1); this.UnloadItemsInSegment(otherMinusThis2); } this._loadedSegment = segment; this._numberOfScrollChangedCalls = this._numberOfScrollChangedCalls + 1; this.ShowStatistics(desiredState); }
public void ShowStatistics(VirtualizableState desiredState) {/* * if (!this._showStatistics) * return; * string str1 = "NumberOfLoadUnload: " + (object)this._numberOfScrollChangedCalls + ", state= " + desiredState.ToString(); * this._loadedSegmentsStr = this._loadedSegment.ToString() + ", " + this._loadedSegmentsStr; * if (this._loadedSegmentsStr.Length >= 40) * this._loadedSegmentsStr = this._loadedSegmentsStr.Substring(0, 40); * string str2 = "LoadedSegment: " + this._loadedSegmentsStr; * this._textBlock1.Text = str1; * this._textBlock1.Foreground = (Brush)new SolidColorBrush(Colors.Green); * this._textBlock1.IsHitTestVisible = false; * this._textBlock2.Text = str2; * this._textBlock2.IsHitTestVisible = false; * this._textBlock2.Foreground = (Brush)new SolidColorBrush(Colors.Green); * if (this._statisticsBlocksAdded) * return; * this._boundToScrollCheckBox.IsChecked = new bool?(true); * this._boundToScrollCheckBox.Checked += new RoutedEventHandler(this._boundToScrollCheckBox_Checked); * this._boundToScrollCheckBox.Unchecked += new RoutedEventHandler(this._boundToScrollCheckBox_Unchecked); * this._statContainer.Children.Add((UIElement)this._textBlock1); * this._statContainer.Children.Add((UIElement)this._textBlock2); * this._statContainer.Children.Add((UIElement)this._boundToScrollCheckBox); * this._statContainer.Orientation = Orientation.Vertical; * this._statContainer.VerticalAlignment = VerticalAlignment.Top; * Grid.SetRowSpan((FrameworkElement)this._statContainer, 10); * Grid.SetColumn((FrameworkElement)this._statContainer, 10); * this.OuterPanel.Children.Add((UIElement)this._statContainer); * this._statisticsBlocksAdded = true;*/ }
private void LoadItemsInSegment(Segment segment, VirtualizableState desiredState) { for (int lowerBound = segment.LowerBound; lowerBound <= segment.UpperBound; ++lowerBound) { IVirtualizable virtualizableItem = this._virtualizableItems[lowerBound]; virtualizableItem.ChangeState(desiredState); this.AddToChildren((UIElement)virtualizableItem.View); } }
public void UpdateLayout() { if (this.CurrentState == VirtualizableState.Unloaded) { return; } VirtualizableState currentState = this.CurrentState; this.ChangeState(VirtualizableState.Unloaded); this.ChangeState(currentState); }
private void _mvm_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "UIStatusDelivered") { VirtualizableState currentState = this.CurrentState; this.Unload(); this.Load(currentState); } if (!(e.PropertyName == "UIDate")) { return; } this._dateTextBlock.Text = this._mvm.UIDate; }
public void ChangeState(VirtualizableState newState) { if (newState == this.CurrentState) { return; } if (newState == VirtualizableState.LoadedFully || newState == VirtualizableState.LoadedPartially) { this.Load(newState); } else { this.Unload(); } }
private void _mvm_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (!(e.PropertyName == "UIStatusDelivered") || this._mvm.UIStatusDelivered != Visibility.Visible || this._handledDelivered) { return; } AttachmentsItem attachmentsItem = Enumerable.FirstOrDefault <IVirtualizable>(this.VirtualizableChildren, (Func <IVirtualizable, bool>)(vc => vc is AttachmentsItem)) as AttachmentsItem; ThumbsItem thumbsItem = (attachmentsItem != null ? Enumerable.FirstOrDefault <IVirtualizable>(attachmentsItem.VirtualizableChildren, (Func <IVirtualizable, bool>)(vc => vc is ThumbsItem)) : null) as ThumbsItem; if (thumbsItem != null) { VirtualizableState currentState = thumbsItem.CurrentState; thumbsItem.ChangeState(VirtualizableState.Unloaded); thumbsItem.PrepareThumbsList(); thumbsItem.ChangeState(currentState); } this._handledDelivered = true; }
public void ShowStatistics(VirtualizableState desiredState) { if (!this._showStatistics) { return; } string str1 = string.Concat(new object[4] { "NumberOfLoadUnload: ", this._numberOfScrollChangedCalls, ", state= ", desiredState.ToString() }); this._loadedSegmentsStr = string.Concat(this._loadedSegment.ToString(), ", ", this._loadedSegmentsStr); if (((string)this._loadedSegmentsStr).Length >= 40) { this._loadedSegmentsStr = ((string)this._loadedSegmentsStr).Substring(0, 40); } string str2 = string.Concat("LoadedSegment: ", this._loadedSegmentsStr); this._textBlock1.Text = str1; this._textBlock1.Foreground = ((Brush) new SolidColorBrush(Colors.Green)); ((UIElement)this._textBlock1).IsHitTestVisible = false; this._textBlock2.Text = str2; ((UIElement)this._textBlock2).IsHitTestVisible = false; this._textBlock2.Foreground = ((Brush) new SolidColorBrush(Colors.Green)); if (this._statisticsBlocksAdded) { return; } ((ToggleButton)this._boundToScrollCheckBox).IsChecked = (new bool?(true)); // ISSUE: method pointer ((ToggleButton)this._boundToScrollCheckBox).Checked += (new RoutedEventHandler(this._boundToScrollCheckBox_Checked)); // ISSUE: method pointer ((ToggleButton)this._boundToScrollCheckBox).Unchecked += (new RoutedEventHandler(this._boundToScrollCheckBox_Unchecked)); ((PresentationFrameworkCollection <UIElement>)((Panel)this._statContainer).Children).Add((UIElement)this._textBlock1); ((PresentationFrameworkCollection <UIElement>)((Panel)this._statContainer).Children).Add((UIElement)this._textBlock2); ((PresentationFrameworkCollection <UIElement>)((Panel)this._statContainer).Children).Add((UIElement)this._boundToScrollCheckBox); this._statContainer.Orientation = ((Orientation)0); ((FrameworkElement)this._statContainer).VerticalAlignment = ((VerticalAlignment)0); Grid.SetRowSpan((FrameworkElement)this._statContainer, 10); Grid.SetColumn((FrameworkElement)this._statContainer, 10); ((PresentationFrameworkCollection <UIElement>) this.OuterPanel.Children).Add((UIElement)this._statContainer); this._statisticsBlocksAdded = true; }
private void _mvm_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "UIStatusDelivered" && this._mvm.UIStatusDelivered == Visibility.Visible && !this._handledDelivered) { VirtualizableState currentState = this.CurrentState; if (currentState != VirtualizableState.Unloaded && this._mvm.StickerAttachment == null) { this.Unload(); this.Load(currentState); } this._handledDelivered = true; } if (e.PropertyName == "BGBrush") { this.UpdateFill(); } if (!(e.PropertyName == "SelectionMarkVisibility")) { return; } ((UIElement)this._selectionPath).Visibility = this._mvm.SelectionMarkVisibility; }
private void PerformLoadUnload(VirtualizableState desiredState) { this.PerformLoadUnload2(desiredState, false); }
private void PerformLoadUnload2(VirtualizableState desiredState, bool bypassUnload = false) { if (this._virtualizableItems.Count == 0) { return; } double realOffset = this.GetRealOffset(); bool flag1 = false; Thickness viewMargin1; if (desiredState == VirtualizableState.LoadedFully || this._loadedSegment.IsEmpty) { flag1 = true; } else { int lowerBound = this._loadedSegment.LowerBound; int upperBound = this._loadedSegment.UpperBound; Thickness viewMargin2 = this._virtualizableItems[lowerBound].ViewMargin; // ISSUE: explicit reference operation double top = ((Thickness)@viewMargin2).Top; viewMargin1 = this._virtualizableItems[upperBound].ViewMargin; // ISSUE: explicit reference operation double num = ((Thickness)@viewMargin1).Top + this._virtualizableItems[upperBound].FixedHeight; if (realOffset - top < 500.0 || num - realOffset < 1500.0) { flag1 = true; } } if (!flag1) { return; } int key = (int)Math.Floor(realOffset - realOffset % this.LoadUnloadThreshold); int num1 = this._thresholdPointIndexes.ContainsKey(key) ? this._thresholdPointIndexes[key] : -1; int upperBoundInd; int lowerBoundInd = upperBoundInd = num1 < 0 ? 0 : num1; int index1 = lowerBoundInd; double num2 = this._isScrolling ? this.LoadedHeightUpwards : this.LoadedHeightDownwardsNotScrolling; double num3 = this._isScrolling ? this.LoadedHeightDownwards : this.LoadedHeightDownwardsNotScrolling; for (; lowerBoundInd > 0; --lowerBoundInd) { double num4 = realOffset; viewMargin1 = this._virtualizableItems[lowerBoundInd].ViewMargin; // ISSUE: explicit reference operation double top = ((Thickness)@viewMargin1).Top; if (num4 - top >= num2) { break; } } bool flag2 = false; bool flag3 = false; for (; upperBoundInd < this._virtualizableItems.Count - 1; ++upperBoundInd) { viewMargin1 = this._virtualizableItems[upperBoundInd].ViewMargin; // ISSUE: explicit reference operation if (((Thickness)@viewMargin1).Top - realOffset < num3) { if (!flag2) { viewMargin1 = this._virtualizableItems[upperBoundInd].ViewMargin; // ISSUE: explicit reference operation if (((Thickness)@viewMargin1).Top >= realOffset) { viewMargin1 = this._virtualizableItems[upperBoundInd].ViewMargin; // ISSUE: explicit reference operation if (((Thickness)@viewMargin1).Top - realOffset > 300.0 && upperBoundInd > 0) { index1 = upperBoundInd - 1; flag3 = true; } else { index1 = upperBoundInd; } flag2 = true; } } } else { break; } } this.SetLoadedBounds(lowerBoundInd, upperBoundInd, desiredState, bypassUnload); if (flag2) { if (flag3) { this._virtualizableItems[index1 + 1].IsOnScreen(); } this._virtualizableItems[index1].IsOnScreen(); } if (!this._enableLog) { return; } string str = "Loaded indexes : "; for (int index2 = 0; index2 < this._virtualizableItems.Count; ++index2) { if (this._virtualizableItems[index2].CurrentState != VirtualizableState.Unloaded) { str = string.Concat(str, index2, ","); } } this.Log(str); }