public RrcTextEditor() { ScrollViewerHelper.SetMouseWheelHelp(this, true); PreviewMouseRightButtonDown += ApiTextEditorPreviewMouseRightButtonDown; Loaded += ApiTextEditorLoaded; }
protected override void OnMouseWheel(MouseWheelEventArgs e) { if (e.Handled) { return; } ScrollViewerHelper.OnMouseWheel(this, e); e.Handled = true; }
private void WorkListBox_Loaded(object sender, RoutedEventArgs e) { if (galleries.Count == 0) { LoadGalleries(); scrollViewerHelper = new ScrollViewerHelper(); scrollViewerHelper.Register(WorkListBox, (uint)ItemBridge.Height, () => { LoadMoreGalleries(); }); } }
internal void HandlePageDownNavigation() { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); if (dataGridContext == null) { return; } DataGridControl dataGridControl = dataGridContext.DataGridControl; FrameworkElement hostPanel = dataGridControl.ItemsHost; if (hostPanel != null) { // First thing to do here is the force the relayout of the ItemsHostPanel so that the target element gets "visible" hostPanel.UpdateLayout(); // Then retrieve the last visible item in this panel FrameworkElement lastVisibleItem = ScrollViewerHelper.GetLastVisibleContainer( dataGridControl, hostPanel, this) as FrameworkElement; if (lastVisibleItem != null) { DataGridContext lastVisibleItemDataGridContext = DataGridControl.GetDataGridContext(lastVisibleItem); object oldItem = dataGridContext.InternalCurrentItem; bool focused; // Make the last visible item the current and focused. // in order to cancel the current column in mixed mode when paged-Down if (dataGridControl.NavigationBehavior == NavigationBehavior.RowOrCell) { focused = dataGridControl.SetFocusHelper( lastVisibleItem, null, true, true); } else { focused = dataGridControl.SetFocusHelper( lastVisibleItem, lastVisibleItemDataGridContext.CurrentColumn, true, true); } if (((!focused) || (oldItem == lastVisibleItemDataGridContext.InternalCurrentItem)) && (!dataGridControl.HasValidationError)) { // The current item was already the first item, move focus down. DataGridItemsHost.ProcessMoveFocus(Key.Down); } } } }
protected virtual void HandlePageDownKey(KeyEventArgs e) { if (e.Handled) { return; } DataGridContext dataGridContext = null; if (e.OriginalSource != null) { dataGridContext = DataGridControl.GetDataGridContext(e.OriginalSource as DependencyObject); } else { dataGridContext = DataGridControl.GetDataGridContext(this); } if (dataGridContext == null) { return; } DataGridControl dataGridControl = dataGridContext.DataGridControl; PagingBehavior pagingBehavior = dataGridControl.PagingBehavior; NavigationBehavior navigationBehavior = dataGridControl.NavigationBehavior; // If the Ctrl Modifier was held at the same time if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { // Scroll to absolute end of the scroll viewer if (pagingBehavior == PagingBehavior.TopToBottom) { this.ScrollToBottom(); } else { this.ScrollToRightEnd(); } // Then handle new selection! if (navigationBehavior != NavigationBehavior.None) { this.HandlePageDownNavigation(); } } //No special modifiers were held else { FrameworkElement lastVisibleContainer = ScrollViewerHelper.GetLastVisibleContainer( dataGridControl, dataGridControl.ItemsHost, this); if (lastVisibleContainer != null) { // There is an identified weakness with the IsKeyboardFocusWithin property where // it cannot tell if the focus is within a Popup which is within the element // This has been identified, and only the places where it caused problems // were fixed... This comment is only here to remind developpers of the flaw // If the item has keyboard focus if ((lastVisibleContainer.IsKeyboardFocusWithin) || (lastVisibleContainer.IsKeyboardFocused) || (navigationBehavior == NavigationBehavior.None)) { // Then scroll if (pagingBehavior == PagingBehavior.TopToBottom) { this.PageDown(); } else { this.PageRight(); } } //and process new selection if (navigationBehavior != NavigationBehavior.None) { this.HandlePageDownNavigation(); } } else { // Normaly for when we are in dataGridControl.NavigationBehavior == NavigationBehavior.None if (pagingBehavior == PagingBehavior.TopToBottom) { this.PageDown(); } else { this.PageRight(); } } } e.Handled = true; }
private bool AddColtrols(int addWhat, int[] things, String anothers1) { /* addWhat - 创建什么, another,anothers - 其他数据 * 1 - 普通卡片 * 2 - 普通事件 */ if (addWhat == 1) { Card card = new Card(); StackPanel stackPanel = new StackPanel(); Grid grid = new Grid(); TextBlock textBlock = new TextBlock(); Button button = new Button(); ListView listView = new ListView(); ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "删除卡片"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(CD_Del); contextMenu.Items.Add(menuItem1); contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); textBlock.ContextMenu = contextMenu; card.ContextMenu = contextMenu; card.PreviewMouseRightButtonDown += WhatFuckOpenMeMe; textBlock.Text = things[0] + ". " + anothers1; textBlock.HorizontalAlignment = HorizontalAlignment.Left; textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Margin = new Thickness(34, 25, 34, 10); textBlock.Foreground = baseColora.Fg; textBlock.FontFamily = baseColora.Fonts; textBlock.FontSize = 15; button.Foreground = baseColora.Fg; button.Margin = new Thickness(0, 10, 15, 0); button.Name = "BCDD" + things[0]; button.Width = 30; button.Click += DelCard_Click; button.HorizontalAlignment = HorizontalAlignment.Right; ButtonHelper.SetIcon(button, ""); IconHelper.SetFontSize(button, 16); ButtonHelper.SetButtonStyle(button, ButtonStyle.Link); card.Name = "CDD" + things[0]; card.Margin = new Thickness(5, 15, 20, 5); card.Width = 540; card.Background = baseColora.Card; grid.Children.Add(textBlock); grid.Children.Add(button); stackPanel.Children.Add(grid); card.Content = stackPanel; ScrollViewerHelper.SetScrollBarCornerRadius(listView, new CornerRadius(3)); stackPanel.Children.Add(listView); MainIn.Children.Add(card); RegisterName("CDD" + things[0], card); } else if (addWhat == 2) { Card card = GetChildObjects <Card>(MainIn, "CDD" + things[1].ToString()); if (card == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片。卡片名称:CDD" + things[1], false); return(false); } List <StackPanel> lstControl = GetChildObjects <StackPanel>(card, typeof(StackPanel)); if (lstControl == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件。卡片名称:CDD" + things[1], false); return(false); } List <ListView> lstControl1 = GetChildObjects <ListView>(lstControl[0], typeof(ListView)); if (lstControl1 == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件中的列表控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件中的列表控件。卡片名称:CDD" + things[1], false); return(false); } ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "完成"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Fin); contextMenu.Items.Add(menuItem1); menuItem2.Name = "MenuItem2"; menuItem2.Header = "删除"; menuItem2.Icon = ""; menuItem2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Del); if (things[2] == 0) { contextMenu.Items.Add(menuItem2); } contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); ListViewItem listViewItem = new ListViewItem(); listViewItem.Name = "CDD" + things[1] + "IT" + things[0]; listViewItem.ContextMenu = contextMenu; listViewItem.PreviewMouseRightButtonDown += WhatFuckOpenMe; TextBlock textBlock = new TextBlock(); textBlock.Text = anothers1; textBlock.Background = baseColora.Tran; textBlock.FontFamily = baseColora.Fonts; textBlock.Foreground = baseColora.Font; textBlock.FontSize = 15; textBlock.Margin = new Thickness(38, 5, 38, 5); listViewItem.Content = textBlock; lstControl1[0].Items.Add(listViewItem); } return(true); }