public ScrollPanel() { VerticalScrollBarVisibility = ScrollBarVisibility.Auto; HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; Effect = new DropShadowEffect() { BlurRadius = 10, Direction = 270, RenderingBias = RenderingBias.Performance, ShadowDepth = 0 }; Panel = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Center }; VirtualizingPanel.SetIsVirtualizing(Panel, true); VirtualizingPanel.SetVirtualizationMode(Panel, VirtualizationMode.Recycling); Content = Panel; ZoomMode = PdfViewerZoomMode.FitHeight; Rotate = PdfRotation.Rotate0; Flags = PdfRenderFlags.None; PagesDisplayMode = PdfViewerPagesDisplayMode.SinglePageMode; MouseWheelMode = MouseWheelMode.PanAndZoom; Dpi = 96; ScrollWidth = 50; Zoom = 1; ZoomMin = DefaultZoomMin; ZoomMax = DefaultZoomMax; ZoomFactor = DefaultZoomFactor; FrameSpace = new Thickness(5); }
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(); }); }
public ListControl() { BorderThickness = new System.Windows.Thickness(0); SelectionMode = SelectionMode.Multiple; VirtualizingPanel.SetIsVirtualizing(this, true); VirtualizingPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling); PreviewKeyDown += ListControl_PreviewKeyDown; }
public TreeList() { VirtualizingPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling); IsSynchronizedWithCurrentItem = true; ItemsPanel = GetItemsPanelTemplate(); set_CanSelectMultiple(this, false); SizeChanged += OnSizeChanged; KeyDown += OnKeyDown; MouseLeftButtonDown += TreeList_MouseLeftButtonDown; }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { if (e.OldElement != null) // Clear old element event { e.OldElement.ItemSelected -= OnElementItemSelected; e.OldElement.ScrollToRequested -= OnElementScrollToRequested; var templatedItems = ((ITemplatedItemsView <Cell>)e.OldElement).TemplatedItems; templatedItems.CollectionChanged -= OnCollectionChanged; templatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged; } if (e.NewElement != null) { e.NewElement.ItemSelected += OnElementItemSelected; e.NewElement.ScrollToRequested += OnElementScrollToRequested; if (Control == null) // Construct and SetNativeControl and suscribe control event { var listView = new WList { DataContext = Element, ItemTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["CellTemplate"], Style = (System.Windows.Style)System.Windows.Application.Current.Resources["ListViewTemplate"] }; VirtualizingPanel.SetVirtualizationMode(listView, VirtualizationMode.Recycling); VirtualizingPanel.SetScrollUnit(listView, ScrollUnit.Pixel); SetNativeControl(listView); Control.MouseUp += OnNativeMouseUp; Control.KeyUp += OnNativeKeyUp; Control.TouchUp += OnNativeTouchUp; Control.StylusUp += OnNativeStylusUp; } // Suscribe element events var templatedItems = TemplatedItemsView.TemplatedItems; templatedItems.CollectionChanged += OnCollectionChanged; templatedItems.GroupedCollectionChanged += OnGroupedCollectionChanged; // Update control properties UpdateItemSource(); UpdateHorizontalScrollBarVisibility(); UpdateVerticalScrollBarVisibility(); if (Element.SelectedItem != null) { OnElementItemSelected(null, new SelectedItemChangedEventArgs(Element.SelectedItem, -1)); } } base.OnElementChanged(e); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ControlGameView = Template.FindName("PART_ControlGameView", this) as Control; if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox; if (ListGames != null) { SetListGamesBinding(); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); ScrollToSelectedBehavior.SetEnabled(ListGames, true); if (!DesignerProperties.GetIsInDesignMode(this)) { ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture)); } ListGames.SelectionMode = SelectionMode.Extended; VirtualizingPanel.SetCacheLengthUnit(ListGames, VirtualizationCacheLengthUnit.Item); VirtualizingPanel.SetCacheLength(ListGames, new VirtualizationCacheLength(5)); VirtualizingPanel.SetScrollUnit(ListGames, ScrollUnit.Pixel); VirtualizingPanel.SetIsVirtualizingWhenGrouping(ListGames, true); VirtualizingPanel.SetVirtualizationMode(ListGames, VirtualizationMode.Recycling); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
public WPFGridView() { this.HorizontalGridLinesBrush = new SolidColorBrush(Colors.LightGray); this.VerticalGridLinesBrush = new SolidColorBrush(Colors.LightGray); this.CanUserAddRows = false; this.CanUserDeleteRows = false; this.HeadersVisibility = DataGridHeadersVisibility.Column; this.EnableColumnVirtualization = true; this.EnableRowVirtualization = true; VirtualizingPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling); this.MouseDoubleClick += WPFGridView_MouseDoubleClick; this.DataContextChanged += this.WPFGridView_DataContextChanged; }
/// <summary> /// Updates ItemsOwner object /// </summary> private void Initialize_ItemsOwner() { ItemsOwner = new VirtualizingStackPanel { Width = this.Width, Height = this.Height, FocusVisualStyle = null, }; VirtualizingPanel.SetIsVirtualizing(ItemsOwner, true); VirtualizingPanel.SetCacheLengthUnit(ItemsOwner, VirtualizationCacheLengthUnit.Item); VirtualizingPanel.SetCacheLength(ItemsOwner, new VirtualizationCacheLength(2)); VirtualizingPanel.SetVirtualizationMode(ItemsOwner, VirtualizationMode.Recycling); UpdateFrameworkElement(ItemsOwner, RenderSize, new Rect(RenderSize)); ChildrenGrid.Children.Add(ItemsOwner); }
public TreeViewImpl(ITreeViewServiceImpl treeViewService, IThemeService themeService, IClassificationFormatMapService classificationFormatMapService, Guid guid, TreeViewOptions options) { Guid = guid; this.treeViewService = treeViewService; treeViewListener = options.TreeViewListener; classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.UIMisc); classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged; foregroundBrushResourceKey = options.ForegroundBrushResourceKey ?? "TreeViewForeground"; sharpTreeView = new SharpTreeView(); sharpTreeView.SelectionChanged += SharpTreeView_SelectionChanged; sharpTreeView.CanDragAndDrop = options.CanDragAndDrop; sharpTreeView.AllowDrop = options.AllowDrop; sharpTreeView.AllowDropOrder = options.AllowDrop; VirtualizingPanel.SetIsVirtualizing(sharpTreeView, options.IsVirtualizing); VirtualizingPanel.SetVirtualizationMode(sharpTreeView, options.VirtualizationMode); AutomationPeerMemoryLeakWorkaround.SetInitialize(sharpTreeView, true); sharpTreeView.SelectionMode = options.SelectionMode; sharpTreeView.BorderThickness = new Thickness(0); sharpTreeView.ShowRoot = false; sharpTreeView.ShowLines = false; if (options.IsGridView) { sharpTreeView.SetResourceReference(ItemsControl.ItemContainerStyleProperty, SharpGridView.ItemContainerStyleKey); sharpTreeView.SetResourceReference(FrameworkElement.StyleProperty, "SharpTreeViewGridViewStyle"); } else { // Clear the value set by the constructor. This is required or our style won't be used. sharpTreeView.ClearValue(ItemsControl.ItemContainerStyleProperty); sharpTreeView.SetResourceReference(FrameworkElement.StyleProperty, typeof(SharpTreeView)); } sharpTreeView.GetPreviewInsideTextBackground = () => themeService.Theme.GetColor(ColorType.SystemColorsHighlight).Background; sharpTreeView.GetPreviewInsideForeground = () => themeService.Theme.GetColor(ColorType.SystemColorsHighlightText).Foreground; // Add the root at the end since Create() requires some stuff to have been initialized root = Create(options.RootNode ?? new TreeNodeDataImpl(new Guid(DocumentTreeViewConstants.ROOT_NODE_GUID))); sharpTreeView.Root = root.Node; }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { if (e.OldElement != null) // Clear old element event { e.OldElement.ItemSelected -= OnElementItemSelected; e.OldElement.ScrollToRequested -= OnElementScrollToRequested; var templatedItems = ((ITemplatedItemsView <Cell>)e.OldElement).TemplatedItems; templatedItems.CollectionChanged -= OnCollectionChanged; templatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged; if (_listview != null) { _listview.MouseUp -= OnNativeMouseUp; _listview.KeyUp -= OnNativeKeyUp; _listview.TouchUp -= OnNativeTouchUp; _listview.StylusUp -= OnNativeStylusUp; _listview.Loaded -= ControlOnLoaded; } if (_scrollViewer != null) { _scrollViewer.ScrollChanged -= SendScrolled; } if (Control is object) { Control.SizeChanged -= Grid_SizeChanged; } } if (e.NewElement != null) { e.NewElement.ItemSelected += OnElementItemSelected; e.NewElement.ScrollToRequested += OnElementScrollToRequested; if (_listview == null) // Construct and SetNativeControl and suscribe control event { _listview = new WList { DataContext = Element, ItemTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["CellTemplate"], Style = (System.Windows.Style)System.Windows.Application.Current.Resources["ListViewTemplate"] }; VirtualizingPanel.SetVirtualizationMode(_listview, VirtualizationMode.Recycling); VirtualizingPanel.SetScrollUnit(_listview, ScrollUnit.Pixel); SetNativeControl(_grid); // Setup grid for header/listview/footer Control.RowDefinitions.Add(new System.Windows.Controls.RowDefinition { Height = System.Windows.GridLength.Auto }); Control.RowDefinitions.Add(new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }); Control.RowDefinitions.Add(new System.Windows.Controls.RowDefinition { Height = System.Windows.GridLength.Auto }); WGrid.SetRow(_listview, 1); Control.Children.Add(_listview); _listview.MouseUp += OnNativeMouseUp; _listview.KeyUp += OnNativeKeyUp; _listview.TouchUp += OnNativeTouchUp; _listview.StylusUp += OnNativeStylusUp; _listview.Loaded += ControlOnLoaded; } // Subscribe element events var templatedItems = TemplatedItemsView.TemplatedItems; templatedItems.CollectionChanged += OnCollectionChanged; templatedItems.GroupedCollectionChanged += OnGroupedCollectionChanged; Control.SizeChanged += Grid_SizeChanged; // Update control properties UpdateHeader(); UpdateFooter(); UpdateItemSource(); UpdateHorizontalScrollBarVisibility(); UpdateVerticalScrollBarVisibility(); if (Element.SelectedItem != null) { OnElementItemSelected(null, new SelectedItemChangedEventArgs(Element.SelectedItem, -1)); } } base.OnElementChanged(e); }