Beispiel #1
0
 public DataGridEx()
 {
     this.Background = new SolidColorBrush(Colors.Transparent);
     // VirtualizintStackPanel
     VirtualizingStackPanel.SetIsVirtualizing(this, true);
     VirtualizingStackPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling);
 }
Beispiel #2
0
        private static TreeViewItem GetTreeViewItem(TreeView treeView, TreeItemViewModel newValue)
        {
            if (newValue == null)
            {
                return(null);
            }

            TreeViewItem treeViewItem = treeView.ItemContainerGenerator.ContainerFromItem(newValue) as TreeViewItem;

            if (treeViewItem == null)
            {
                treeView.UpdateLayout();
                treeViewItem = treeView.ItemContainerGenerator.ContainerFromItem(newValue) as TreeViewItem;
            }
            if (treeViewItem == null)
            {
                int?index = GetIndex(treeView, newValue);
                if (index.HasValue)
                {
                    ItemsPresenter         presenter      = treeView.Template.FindName("ItemsPresenter", treeView) as ItemsPresenter;
                    VirtualizingStackPanel itemsHostPanel = VisualTreeHelper.GetChild(presenter, 0) as VirtualizingStackPanel;
                    itemsHostPanel.BringIndexIntoViewPublic(index.Value);

                    treeViewItem = treeView.ItemContainerGenerator.ContainerFromIndex(index.Value) as TreeViewItem;
                }
            }
            return(treeViewItem);
        }
Beispiel #3
0
        protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
        {
            base.OnItemsSourceChanged(oldValue, newValue);

            var oldCollection = oldValue as INotifyCollectionChanged;
            var newCollection = newValue as INotifyCollectionChanged;

            if (oldCollection != null)
            {
                CollectionChangedEventManager.RemoveListener(oldCollection, this);
            }

            if (newCollection != null)
            {
                CollectionChangedEventManager.AddListener(newCollection, this);
            }

            if (!this.IsInitialized)
            {
                return;
            }

            if (!VirtualizingStackPanel.GetIsVirtualizing(this) ||
                (VirtualizingStackPanel.GetIsVirtualizing(this) && (newValue != null)))
            {
                this.RemoveUnavailableSelectedItems();
            }

            this.UpdateSelectedMemberPathValuesBindings();
            this.UpdateValueMemberPathValuesBindings();
        }
Beispiel #4
0
        public TimelinePanel()
        {
            InitializeComponent();

            /*Timer timer = new Timer();
             * timer.Elapsed += new ElapsedEventHandler(refresh_Timeline);
             * timer.Interval = 60000;
             * timer.Enabled = true;*/

            if (MastodonAPIWrapper.sharedApiWrapper.nightModeEnabled)
            {
                this.Background        = new SolidColorBrush(Color.FromArgb(255, 26, 26, 26));
                title.Foreground       = Brushes.White;
                timelineBox.Background = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50));
            }

            try
            {
                VirtualizingStackPanel.SetScrollUnit(timelineBox, ScrollUnit.Pixel);
                VirtualizingStackPanel.SetIsVirtualizing(timelineBox, true);
                VirtualizingStackPanel.SetVirtualizationMode(timelineBox, VirtualizationMode.Recycling);
                ScrollViewer.SetCanContentScroll(timelineBox, true);
            }
            catch (Exception)
            {
            }
        }
Beispiel #5
0
        private static void OnIsPivotAnimatedChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            LongListSelector list = d as LongListSelector;

            list.Loaded += (s2, e2) =>
            {
                // locate the pivot control that this list is within
                Pivot pivot = list.Ancestors <Pivot>().Single() as Pivot;

                // and its index within the pivot
                int pivotIndex = pivot.Items.IndexOf(list.Ancestors <PivotItem>().Single());

                bool selectionChanged = false;

                pivot.SelectionChanged += (s3, e3) =>
                {
                    selectionChanged = true;
                };

                // handle manipulation events which occur when the user
                // moves between pivot items
                pivot.ManipulationCompleted += (s, e) =>
                {
                    if (!selectionChanged)
                    {
                        return;
                    }

                    selectionChanged = false;

                    if (pivotIndex != pivot.SelectedIndex)
                    {
                        return;
                    }

                    // determine which direction this tab will be scrolling in from
                    bool fromRight = e.TotalManipulation.Translation.X <= 0;

                    // locate the stack panel that hosts the items
                    VirtualizingStackPanel vsp = list.Descendants <VirtualizingStackPanel>().First() as VirtualizingStackPanel;

                    // iterate over each of the items in view
                    var itemsInView = list.GetVisualAncestors();

                    foreach (ContentPresenter item in itemsInView)
                    {
                        var localItem = item;
                        list.Dispatcher.BeginInvoke(() =>
                        {
                            var animationTargets = localItem.Descendants().Where(p => GetAnimationLevel(p) > -1);
                            foreach (FrameworkElement target in animationTargets)
                            {
                                // trigger the required animation
                                GetAnimation(target, fromRight).Begin();
                            }
                        });
                    }
                };
            };
        }
Beispiel #6
0
        //Monitor and handle the scroll viewer
        private async void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            try
            {
                //Get current scroll item
                VirtualizingStackPanel virtualizingStackPanel = AVFunctions.FindVisualChild <VirtualizingStackPanel>(ListView_Items);
                Int32 CurrentOffSetId = (virtualizingStackPanel.Orientation == Orientation.Horizontal) ? (Int32)virtualizingStackPanel.HorizontalOffset : (Int32)virtualizingStackPanel.VerticalOffset;

                //Update the current item count
                textblock_StatusCurrentItem.Tag = (CurrentOffSetId + 1).ToString();
                Int32 HeaderTargetSize  = Convert.ToInt32(stackpanel_Header.Tag);
                Int32 HeaderCurrentSize = Convert.ToInt32(stackpanel_Header.Height);
                if (HeaderCurrentSize == HeaderTargetSize || AppVariables.CurrentTotalItemsCount == 0)
                {
                    textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString();
                }
                else
                {
                    textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString() + "/" + AppVariables.CurrentTotalItemsCount;
                }

                //Update the shown item content
                await EventsScrollViewer.ScrollViewerUpdateContent(ListView_Items, CurrentOffSetId);

                //Check if new items need to be loaded
                await EventsScrollViewer.ScrollViewerAddItems(ListView_Items, CurrentOffSetId);
            }
            catch { }
        }
Beispiel #7
0
        public S7FunctionBlockRow getFirstVisbleExpandedItem()
        {
            Network nw = null;

            VirtualizingStackPanel panel = UIHelpers.TryFindChild <VirtualizingStackPanel>(myLst);

            //ScrollViewer panel = UIHelpers.TryFindChild<ScrollViewer>(myLst);
            if (myLst.Items.Count > 0 && panel != null)
            {
                int offset = (panel.Orientation == Orientation.Horizontal) ? (int)panel.HorizontalOffset : (int)panel.VerticalOffset;

                //var item = UIHelpers.TryFindFromPoint<ListBoxItem>(myLst, new Point(myLst.po,  panel.HorizontalOffset));

                var item = myLst.Items[offset];

                int idx = myLst.Items.IndexOf(item);

                for (int n = idx; n < myLst.Items.Count; n++)
                {
                    var exp = UIHelpers.TryFindChild <Expander>(myLst.ItemContainerGenerator.ContainerFromIndex(n));
                    if (exp.IsExpanded)
                    {
                        return((S7FunctionBlockRow)((S7FunctionBlockNetwork)myLst.Items[n]).AWLCode[0]);
                    }
                }
            }
            return(null);
        }
Beispiel #8
0
        private WatermarkTextBox CreateReplyTextBox(ListBox panel)
        {
            var inputScope = new InputScope();

            inputScope.Names.Add(new InputScopeName()
            {
                NameValue = InputScopeNameValue.Chat
            });

            var textBox = new WatermarkTextBox();

            textBox.AcceptsReturn = true;
            textBox.TextWrapping  = TextWrapping.Wrap;
            textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            textBox.InputScope    = inputScope;
            textBox.WatermarkText = "댓글";
            textBox.Margin        = new Thickness(-10, 0, -10, 0);

            textBox.SizeChanged += (o1, e1) =>
            {
                if (FocusManager.GetFocusedElement() == textBox)
                {
                    VirtualizingStackPanel vstackPanel = (VirtualizingStackPanel)GetChildren(panel).FirstOrDefault(dobj => dobj is VirtualizingStackPanel);
                    if (vstackPanel != null)
                    {
                        vstackPanel.SetVerticalOffset(vstackPanel.ExtentHeight - vstackPanel.ViewportHeight);
                    }
                }
            };

            textBox.GotFocus  += (o1, e1) => UpdateAppBar();
            textBox.LostFocus += (o1, e1) => UpdateAppBar();

            return(textBox);
        }
Beispiel #9
0
        //gets the number of visuals loaded for a particular virtualizing stack panel
        private static int GetVisualCount(DependencyObject visual)
        {
            int visualCount = -1;
            int childCount  = VisualTreeHelper.GetChildrenCount(visual);

            for (int i = 0; i < childCount; i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(visual, i) as DependencyObject;

                //get the child of the stack panel
                StackPanel panel = child as StackPanel;
                if (panel != null)
                {
                    return(panel.Children.Count);
                }
                else
                {
                    //try to parse as a Virtualizing stackPanel
                    VirtualizingStackPanel vpanel = child as VirtualizingStackPanel;
                    if (vpanel != null)
                    {
                        return(vpanel.Children.Count);
                    }
                    else
                    {
                        visualCount = GetVisualCount(child);
                        if (visualCount != -1)
                        {
                            return(visualCount);
                        }
                    }
                }
            }
            return(visualCount);
        }
Beispiel #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GameField Game = ((App)(Application.Current)).Game;

            int offset, gameModeIndex;

            PanelX = FindVisualChild <VirtualizingStackPanel>(FieldSizeX);
            PanelY = FindVisualChild <VirtualizingStackPanel>(FieldSizeY);

            offset = Game.x - sizeFieldOptions[0];
            PanelX.SetVerticalOffset(offset);

            offset = Game.y - sizeFieldOptions[0];
            PanelY.SetVerticalOffset(offset);

            switch (Game.GameMode)
            {
            case GameMode.Player1Player2:
                gameModeIndex = 0;
                break;

            case GameMode.Player1Computer:
                gameModeIndex = 1;
                break;

            default:
                gameModeIndex = 0;
                break;
            }

            GameModeList.SelectedIndex = gameModeIndex;
        }
Beispiel #11
0
        void RefreshDisplayArea()
        {
            var oldFirst = FirstVisibleIndex;
            var oldLast  = LastVisibleIndex;

            if (ItemsSource != null)
            {
                var isVirtualizing = VirtualizingStackPanel.GetIsVirtualizing(this);
                if (!isVirtualizing)
                {
                    CalculateVisibleIndex();
                }
                else if (_orientation == Orientation.Vertical)
                {
                    FirstVisibleIndex = (int)_scrollView.VerticalOffset;
                    var lastIndex = Math.Min(Items.Count - 1, _scrollView.VerticalOffset + _scrollView.ViewportHeight);
                    LastVisibleIndex = (int)lastIndex;
                }
                else
                {
                    FirstVisibleIndex = (int)_scrollView.HorizontalOffset;
                    var lastIndex = Math.Min(Items.Count - 1, _scrollView.HorizontalOffset + _scrollView.ViewportWidth);
                    LastVisibleIndex = (int)lastIndex;
                }
            }
            else
            {
                CalculateVisibleIndex();
            }
            RefreshItemsVisualState(oldFirst, FirstVisibleIndex, oldLast, LastVisibleIndex);
        }
    /// <summary>
    /// Causes the object to scroll into view centered.
    /// </summary>
    /// <param name="listBox">ListBox instance.</param>
    /// <param name="item">Object to scroll.</param>
    //[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
    //    Justification = "Deliberately targeting ListBox.")]
    public static void ScrollIntoViewTop(this ListBox listBox, object item)
    {
        Debug.Assert(!VirtualizingStackPanel.GetIsVirtualizing(listBox),
                     "VirtualizingStackPanel.IsVirtualizing must be disabled for ScrollIntoViewCentered to work.");
        // Get the container for the specified item
        var container = listBox.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement;

        if (null != container)
        {
            if (ScrollViewer.GetCanContentScroll(listBox))
            {
                // Get the parent IScrollInfo
                var scrollInfo = VisualTreeHelper.GetParent(container) as IScrollInfo;
                if (null != scrollInfo)
                {
                    // Need to know orientation, so parent must be a known type
                    var stackPanel             = scrollInfo as StackPanel;
                    var virtualizingStackPanel = scrollInfo as VirtualizingStackPanel;
                    Debug.Assert((null != stackPanel) || (null != virtualizingStackPanel),
                                 "ItemsPanel must be a StackPanel or VirtualizingStackPanel for ScrollIntoViewCentered to work.");
                    // Get the container's index
                    var index = listBox.ItemContainerGenerator.IndexFromContainer(container);
                    // Center the item by splitting the extra space
                    if (((null != stackPanel) && (Orientation.Horizontal == stackPanel.Orientation)) ||
                        ((null != virtualizingStackPanel) && (Orientation.Horizontal == virtualizingStackPanel.Orientation)))
                    {
                        //scrollInfo.SetHorizontalOffset(index - Math.Floor(scrollInfo.ViewportWidth / 2));
                        scrollInfo.SetHorizontalOffset(index);
                    }
                    else
                    {
                        //scrollInfo.SetVerticalOffset(index - Math.Floor(scrollInfo.ViewportHeight / 2));
                        scrollInfo.SetVerticalOffset(index);
                    }
                }
            }
            else
            {
                // Get the bounds of the item container
                var rect = new Rect(new Point(), container.RenderSize);
                // Find constraining parent (either the nearest ScrollContentPresenter or the ListBox itself)
                FrameworkElement constrainingParent = container;
                do
                {
                    constrainingParent = VisualTreeHelper.GetParent(constrainingParent) as FrameworkElement;
                } while ((null != constrainingParent) &&
                         (listBox != constrainingParent) &&
                         !(constrainingParent is ScrollContentPresenter));
                if (null != constrainingParent)
                {
                    // Inflate rect to fill the constraining parent
                    rect.Inflate(
                        Math.Max((constrainingParent.ActualWidth - rect.Width) / 2, 0),
                        Math.Max((constrainingParent.ActualHeight - rect.Height) / 2, 0));
                }
                // Bring the (inflated) bounds into view
                container.BringIntoView(rect);
            }
        }
    }
Beispiel #13
0
        /// <summary>
        /// Enumerates all the items that are currently visible in an ItemsControl. This
        /// implementation works for both virtualized and non-virtualized panels.
        /// </summary>
        public static IEnumerable <FrameworkElement> GetItemsInView(this ItemsControl itemsControl)
        {
            // find the panel that hosts our items - this is 'cached'
            // using the ItemsControl.Tag property to minimize visual tree
            // navigation
            Panel itemsHostPanel = itemsControl.Tag as Panel;

            if (itemsHostPanel == null)
            {
                itemsHostPanel = itemsControl.Descendants <Panel>()
                                 .Cast <Panel>()
                                 .Where(p => p.IsItemsHost)
                                 .SingleOrDefault();
                itemsControl.Tag = itemsHostPanel;
            }

            VirtualizingStackPanel vsp = itemsHostPanel as VirtualizingStackPanel;

            if (vsp != null)
            {
                // implementation for virtualizing lists
                return(GetItemsInView(itemsControl, vsp));
            }
            else
            {
                // implementation for non-virtualizing lists
                return(Enumerable.Range(0, itemsControl.Items.Count)
                       .Select(index => itemsControl.ItemContainerGenerator.ContainerFromIndex(index))
                       .Cast <FrameworkElement>()
                       .Where(container => container.GetRelativePosition(itemsControl).Y + container.ActualHeight > 0)
                       .Where(container => container.GetRelativePosition(itemsControl).Y - container.ActualHeight < itemsControl.ActualHeight));
            }
        }
Beispiel #14
0
        /// <summary>
        /// Registrating an item of the list.
        /// </summary>
        /// <param name="index">An index of item into the source collection.</param>
        /// <returns></returns>
        protected override FrameworkElement ItemRegistration(int index)
        {
            // Getting base element.
            var element = base.ItemRegistration(index);

            // Adding spliters if requested.
            if (SplitersDraw)
            {
                // Instiniating panel that will contains the layout.
                var panel = new VirtualizingStackPanel()
                {
                    Orientation = Orientation.Vertical
                };

                // Instiniating spliter.
                var spliter = new Grid()
                {
                    Height           = 1,
                    MaxHeight        = 1,
                    Background       = SpliterColor,
                    Margin           = new Thickness(-3, 3, -3, 0),
                    IsHitTestVisible = false
                };

                // Add new elements to the layout parent.
                panel.Children.Add(element);
                panel.Children.Add(spliter);

                // Returning parent as target element.
                return(panel);
            }

            // Returning defult element.
            return(element);
        }
 public FolderDataPersenter(ContextMenu folderContextMenu)
 {
     VirtualizingStackPanel.SetIsVirtualizing(this, true);
     this.Focusable         = false;
     this.folderContextMenu = folderContextMenu;
     this.ContextMenu       = folderContextMenu;
 }
Beispiel #16
0
        public static void SetStyles()
        {
            Eto.Style.Add <Eto.Forms.Button>("main", button =>
            {
                var wpfbutton             = (Button)button.ControlObject;
                wpfbutton.BorderThickness = new Thickness(0.0);
                var img    = (Image)((Grid)wpfbutton.Content).Children[0];
                img.Margin = new Thickness(5.0d);
                var label  = (Label)((Grid)wpfbutton.Content).Children[1];
                label.HorizontalAlignment = HorizontalAlignment.Left;
                TextOptions.SetTextRenderingMode(label, TextRenderingMode.Auto);
            });

            Eto.Style.Add <Eto.Forms.Button>("donate", button =>
            {
                var wpfbutton             = (Button)button.ControlObject;
                wpfbutton.BorderThickness = new Thickness(0.0);
                var img    = (Image)((Grid)wpfbutton.Content).Children[0];
                img.Margin = new Thickness(5.0d);
                var label  = (Label)((Grid)wpfbutton.Content).Children[1];
                label.HorizontalAlignment = HorizontalAlignment.Left;
                TextOptions.SetTextRenderingMode(label, TextRenderingMode.Auto);
            });

            Eto.Style.Add <Eto.Forms.Panel>("transparent-form", control =>
            {
                var wpfwnd = (System.Windows.Window)control.ControlObject;
                TextOptions.SetTextRenderingMode(wpfwnd, TextRenderingMode.Auto);
                wpfwnd.AllowsTransparency = true;
                wpfwnd.Background         = Brushes.Transparent;
            });

            Eto.Style.Add <Eto.Forms.TextBox>("textbox-rightalign", control =>
            {
                var tbox           = (System.Windows.Controls.TextBox)control.ControlObject;
                tbox.TextAlignment = TextAlignment.Right;
            });

            Eto.Style.Add <Eto.Forms.GridView>("spreadsheet", control =>
            {
                var wpfgrid           = (Eto.Wpf.Forms.Controls.EtoDataGrid)control.ControlObject;
                wpfgrid.SelectionUnit = DataGridSelectionUnit.Cell;
                var style             = new Style(typeof(DataGridColumnHeader));
                style.Setters.Add(new Setter(DataGrid.HorizontalContentAlignmentProperty, HorizontalAlignment.Center));
                wpfgrid.ColumnHeaderStyle          = style;
                wpfgrid.ColumnWidth                = new DataGridLength(100, DataGridLengthUnitType.Pixel);
                wpfgrid.HeadersVisibility          = DataGridHeadersVisibility.All;
                wpfgrid.RowHeaderWidth             = 50;
                wpfgrid.EnableColumnVirtualization = true;
                wpfgrid.EnableRowVirtualization    = true;
                VirtualizingPanel.SetVirtualizationMode(wpfgrid, VirtualizationMode.Recycling);
                VirtualizingStackPanel.SetIsVirtualizing(wpfgrid, true);
                wpfgrid.LoadingRow += (sender, e) =>
                {
                    e.Row.Header = (e.Row.GetIndex() + 1).ToString();
                };
                wpfgrid.UpdateLayout();
            });
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of this control.
        /// </summary>
        public InnerList()
            : base()
        {
            // This flag is needed to dramatically increase performance of scrolling \\
            VirtualizingStackPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling);

            AutomationProperties.SetAutomationId(this, "InnerList"); // No localization needed
        }
Beispiel #18
0
 public CarouselPageRenderer()
 {
     VirtualizingStackPanel.SetVirtualizationMode(this, VirtualizationMode.Standard);
     ItemTemplate      = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["ContainedPageTemplate"];
     SelectionChanged += OnSelectionChanged;
     Loaded           += OnLoaded;
     Unloaded         += OnUnloaded;
 }
Beispiel #19
0
 private async Task ApplyFlipViewOrientation(Orientation orientation)
 {
     await RunOnUIThreadAsync(CoreDispatcherPriority.Normal, () =>
     {
         VirtualizingStackPanel panel = (VirtualizingStackPanel)FlipViewPages.ItemsPanelRoot;
         panel.Orientation            = orientation;
     });
 }
Beispiel #20
0
 private static void PrintListBoxState(ItemsControl listBox, StringBuilder outPut)
 {
     outPut.AppendLine("ListBoxの状態");
     outPut.AppendLine(listBox.ItemContainerGenerator.Status.ToString());
     outPut.AppendLine(string.Format("ItemsPanel: {0}", listBox.ItemsPanel.VisualTree.Type));
     outPut.AppendLine(string.Format("{0}", VirtualizingStackPanel.GetVirtualizationMode(listBox)));
     outPut.AppendLine(string.Format("{0}", BAR));
 }
Beispiel #21
0
        private void ListBox_Loaded(object sender, RoutedEventArgs e)
        {
            if (_isInitialized)
            {
                return;
            }

            _isInitialized = true;

            AddHandler(ManipulationCompletedEvent, new EventHandler <ManipulationCompletedEventArgs>(ListBox_ManipulationCompleted), true);

            _scrollViewer = this.FindChildOfType <ScrollViewer>();

            if (_scrollViewer != null)
            {
                _stackPanel = _scrollViewer.FindChildOfType <VirtualizingStackPanel>();

                if (IsHorizontal)
                {
                    ToHorizontalOrientation();
                }
                else
                {
                    ToVerticalOrientation();
                }
                // Visual States are always on the first child of the control template
                var element = VisualTreeHelper.GetChild(_scrollViewer, 0) as FrameworkElement;
                if (element != null)
                {
                    var verticalGroup     = FindVisualState(element, VerticalCompressionGroup);
                    var horizontalGroup   = FindVisualState(element, HorizontalCompressionGroup);
                    var scrollStatesGroup = FindVisualState(element, ScrollStatesGroup);

                    if (verticalGroup != null)
                    {
                        verticalGroup.CurrentStateChanging += VerticalGroup_CurrentStateChanging;
                    }
                    if (horizontalGroup != null)
                    {
                        horizontalGroup.CurrentStateChanging += HorizontalGroup_CurrentStateChanging;
                    }
                    if (scrollStatesGroup != null)
                    {
                        scrollStatesGroup.CurrentStateChanging += ScrollStateGroup_CurrentStateChanging;
                    }
                }


                if (!SuppressVerticalOffsetListener)
                {
                    var binding = new Binding("VerticalOffset")
                    {
                        Source = _scrollViewer
                    };
                    SetBinding(VerticalOffsetProperty, binding);
                }
            }
        }
Beispiel #22
0
        private void DynamicGrid_Loaded(object sender, RoutedEventArgs e)
        {
            VirtualizingStackPanel itemsPanel = GetVisualChild <VirtualizingStackPanel>(DynamicItems);

            if (itemsPanel != null && itemsPanel.IsItemsHost)
            {
                itemsPanel.PreviewMouseLeftButtonDown += delegate { MessageBox.Show("WPF"); };
            }
        }
Beispiel #23
0
        private static void InvokeBringIndexIntoView(VirtualizingStackPanel panel, int index)
        {
            var itemsOwner = ItemsControl.GetItemsOwner(panel);

            if (itemsOwner != null && index >= 0 && index < itemsOwner.Items.Count)
            {
                s_bringIntoViewMethod.Invoke(panel, new object[] { index });
            }
        }
 /// <summary>
 ///     Helper method which invalidate the underlying itemshost's measure and arrange
 /// </summary>
 /// <param name="withColumnVirtualization">
 ///     True to invalidate only when virtualization is on.
 ///     False to invalidate only when virtualization is off.
 /// </param>
 private void InvalidateDataGridCellsPanelMeasureAndArrange(bool withColumnVirtualization)
 {
     // Invalidates measure and arrange if the flag and the virtualization
     // are either both true or both false.
     if (withColumnVirtualization == VirtualizingStackPanel.GetIsVirtualizing(this))
     {
         InvalidateDataGridCellsPanelMeasureAndArrange();
     }
 }
        /// <summary>
        /// Retrieves the ListBox's items panel as VirtualizingStackPanel.
        /// </summary>
        /// <param name="listBox">The ListBox</param>
        /// <returns>The item panel or null if no VirtualizingStackPanel was found</returns>
        public static VirtualizingStackPanel GetPanel(this ListBox listBox)
        {
            VirtualizingStackPanel panel = UIHelpers.TryFindChild <VirtualizingStackPanel>(listBox);

            if (panel == null)
            {
                Debug.WriteLine("No VirtualizingStackPanel found for ListBox.");
            }
            return(panel);
        }
Beispiel #26
0
        private ComboBoxItem GetComboxItem(ComboBox container)
        {
            if (container != null)
            {
                // Try to generate the ItemsPresenter and the ItemsPanel.
                // by calling ApplyTemplate.  Note that in the
                // virtualizing case even if the item is marked
                // expanded we still need to do this step in order to
                // regenerate the visuals because they may have been virtualized away.

                container.ApplyTemplate();
                ItemsPresenter itemsPresenter = FindVisualChild <ItemsPresenter>(container);
                if (itemsPresenter == null)
                {
                    container.UpdateLayout();

                    itemsPresenter = FindVisualChild <ItemsPresenter>(container);
                }

                Panel itemsHostPanel = (Panel)VisualTreeHelper.GetChild(itemsPresenter, 0);

                // Ensure that the generator for this panel has been created.
                UIElementCollection children = itemsHostPanel.Children;

                VirtualizingStackPanel virtualizingPanel =
                    itemsHostPanel as VirtualizingStackPanel;

                for (int i = 0, count = container.Items.Count; i < count; i++)
                {
                    ComboBoxItem subContainer;
                    if (virtualizingPanel != null)
                    {
                        // Bring the item into view so
                        // that the container will be generated.
                        //virtualizingPanel.BringIntoView(i);

                        subContainer =
                            (ComboBoxItem)container.ItemContainerGenerator.
                            ContainerFromIndex(i);
                    }
                    else
                    {
                        subContainer =
                            (ComboBoxItem)container.ItemContainerGenerator.
                            ContainerFromIndex(i);

                        // Bring the item into view to maintain the
                        // same behavior as with a virtualizing panel.
                        subContainer.BringIntoView();
                    }
                }
            }

            return(null);
        }
Beispiel #27
0
        public TabPlaylist()
        {
            this.InitializeComponent();
#if NET40
            //VirtualizingStackPanel.IsVirtualizingWhenGrouping is not supported.
            //The behaviour which requires this feature is disabled.
#else
            VirtualizingStackPanel.SetIsVirtualizingWhenGrouping(this.ListView, true);
#endif
            this.IsVisibleChanged += this.OnIsVisibleChanged;
        }
Beispiel #28
0
        private void ScrollQuestionsTo(int index)
        {
            VirtualizingStackPanel vsp =
                (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember("_itemsHost",
                                                                          BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null,
                                                                          lvQuestions, null);

            double scrollHeight = vsp.ScrollOwner.ScrollableHeight;
            double offset       = scrollHeight * index / lvQuestions.Items.Count;

            vsp.SetVerticalOffset(offset);
        }
Beispiel #29
0
        private void ImagesView_LayoutUpdated(object sender, object e)
        {
            if (VSP == null)
            {
                VSP = ImagesView.ChildAt <VirtualizingStackPanel>(0, 0, 0, 0, 0, 0, 1);
            }

            if (VSP != null && TryResetZoom(ImagesView.SelectedItem))
            {
                ImagesView.LayoutUpdated -= ImagesView_LayoutUpdated;
            }
        }
Beispiel #30
0
        private void Analyze(bool full)
        {
            var state  = GetCurrentState();
            var viewer = new ScrollViewer();
            var panel  = new VirtualizingStackPanel();

            viewer.Content = panel;
            UXHeader.Text  = $"{"Address",20} {"Offset",10} {(full ? $"{"Value",10}" : "")}{"Blk",26} {"Blk.Ofs",10} {"Blk.Size",10}";
            IHeapNode blk = null;

            for (int i = 0; i < (int)state.Size; i += (full && blk == null) ? 4 : _ctx.Memory.Reader.PointerSize)
            {
                var ptr = _ctx.Memory.Reader.Read <Ptr>(state.Start + i);
                blk = i % _ctx.Memory.Reader.PointerSize == 0 ? _idx.FindNode(ptr.ValueAddress) : null;
                var line = "";

                if (blk != null || full)
                {
                    line += $"{state.Start + i,26:X16} {i,10:X3}";
                    if (full)
                    {
                        line += $" {_ctx.Memory.Reader.Read<int>(state.Start + i),10:X} ({new string(_ctx.Memory.Reader.Read<byte>(state.Start + i, 4).Select(b => (char)b).Select(c => c >= 0x20 && c <= 0x7E ? c : ' ').ToArray()),4})";
                    }
                }
                if (blk != null)
                {
                    var offset = (int)(ptr.ValueAddress - blk.Data.ValueAddress);
                    line += $" {blk.Address.ToString(),26} {offset,10:X} {blk.Size,10}";
                    if (ptr.ValueAddress >= state.Start && ptr.ValueAddress < state.Start + state.Size)
                    {
                        line += $" this+{ptr.ValueAddress - state.Start:X}";
                    }

                    var link = new Hyperlink(new Run {
                        Text = line
                    });
                    link.Tag    = new Segment(blk.Data.ValueAddress, blk.Size);
                    link.Click += Link_Click;
                    panel.Children.Add(new TextBlock(link)
                    {
                        FontFamily = new FontFamily("Consolas")
                    });
                }
                else if (full)
                {
                    panel.Children.Add(new TextBlock {
                        Text = line, FontFamily = new FontFamily("Consolas")
                    });
                }
            }

            UXView.Content = viewer;
        }
      public LayoutSuspendedHelper( VirtualizingStackPanel panel, Orientation orientation )
      {
        if( panel == null )
          throw new ArgumentNullException( "panel" );

        m_panel = panel;

        m_panel.m_layoutSuspendedOrientation = orientation;
        m_panel.m_layoutSuspended = true;
      }