private void HandleRightClick(object sender, RoutedEventArgs e) { var rowPressed = DependencyObjectHelpers.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); if (rowPressed != null) { var objectPressed = ((IList <ListedItem>)AllView.ItemsSource).ElementAtOrDefault(rowPressed.GetIndex()); if (objectPressed == null) { return; } // Check if RightTapped row is currently selected if (IsItemSelected) { if (SelectedItems.Contains(objectPressed)) { return; } } // The following code is only reachable when a user RightTapped an unselected row SetSelectedItemOnUi(objectPressed); } }
private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e) { var parentContainer = DependencyObjectHelpers.FindParent <GridViewItem>(e.OriginalSource as DependencyObject); if (!parentContainer.IsSelected) { ItemManipulationModel.SetSelectedItem(FileList.ItemFromContainer(parentContainer) as ListedItem); } }
private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e) { var parentContainer = DependencyObjectHelpers.FindParent <ListViewItem>(e.OriginalSource as DependencyObject); if (parentContainer.IsSelected) { return; } // The following code is only reachable when a user RightTapped an unselected row ItemManipulationModel.SetSelectedItem(FileList.ItemFromContainer(parentContainer) as ListedItem); }
private void RectangleSelection_PointerPressed(object sender, PointerRoutedEventArgs e) { itemsPosition.Clear(); dataGridRows.Clear(); DependencyObjectHelpers.FindChildren <DataGridRow>(dataGridRows, uiElement); // Find visible/loaded rows prevSelectedItems = uiElement.SelectedItems.Cast <object>().ToList(); // Save current selected items originDragPoint = new Point(e.GetCurrentPoint(uiElement).Position.X, e.GetCurrentPoint(uiElement).Position.Y); // Initial drag point relative to the topleft corner var verticalOffset = (scrollBar?.Value ?? 0) - uiElement.ColumnHeaderHeight; originDragPoint.Y += verticalOffset; // Initial drag point relative to the top of the list (considering scrolled offset) if (!e.GetCurrentPoint(uiElement).Properties.IsLeftButtonPressed || e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch) { // Trigger only on left click, do not trigger with touch return; } var clickedRow = DependencyObjectHelpers.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); if (clickedRow != null && uiElement.SelectedItems.Contains(clickedRow.DataContext)) { // If the item under the pointer is selected do not trigger selection rectangle return; } var selectedItems = new GenericItemsCollection <object>(uiElement.SelectedItems); selectionStrategy = e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control) ? new InvertPreviousItemSelectionStrategy(selectedItems, prevSelectedItems) : e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift) ? (ItemSelectionStrategy) new ExtendPreviousItemSelectionStrategy(selectedItems, prevSelectedItems) : new IgnorePreviousItemSelectionStrategy(selectedItems); if (clickedRow == null) { // If user click outside, reset selection if (uiElement.CurrentColumn != null) { uiElement.CancelEdit(); } DeselectGridCell(); selectionStrategy.HandleNoItemSelected(); } uiElement.PointerMoved -= RectangleSelection_PointerMoved; uiElement.PointerMoved += RectangleSelection_PointerMoved; if (selectionChanged != null) { // Unsunscribe from SelectionChanged event for performance uiElement.SelectionChanged -= selectionChanged; } uiElement.CapturePointer(e.Pointer); selectionState = SelectionState.Starting; }
private void HandleRightClick(object sender, RoutedEventArgs e) { var rowPressed = DependencyObjectHelpers.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); var objectPressed = rowPressed == null ? null : ((IList <ListedItem>)AllView.ItemsSource).ElementAtOrDefault(rowPressed.GetIndex()); if (rowPressed == null || objectPressed == null) { // Clear the selection if no item was clicked ItemManipulationModel.ClearSelection(); } else if (!IsItemSelected || !SelectedItems.Contains(objectPressed)) { // Select item if it is not already selected ItemManipulationModel.SetSelectedItem(objectPressed); } }
private async void Properties_Loaded(object sender, RoutedEventArgs e) { AppSettings.ThemeModeChanged += AppSettings_ThemeModeChanged; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { // Set window size in the loaded event to prevent flickering TitleBar = ApplicationView.GetForCurrentView().TitleBar; TitleBar.ButtonBackgroundColor = Colors.Transparent; TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => AppSettings.UpdateThemeElements.Execute(null)); } else { propertiesDialog = DependencyObjectHelpers.FindParent <ContentDialog>(this); propertiesDialog.Closed += PropertiesDialog_Closed; } }
protected override void Page_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args) { if (ParentShellPageInstance != null) { if (ParentShellPageInstance.CurrentPageType == typeof(GenericFileBrowser)) { // Don't block the various uses of enter key (key 13) var focusedElement = FocusManager.GetFocusedElement() as FrameworkElement; if (args.KeyCode == 13 || focusedElement is Button || focusedElement is TextBox || focusedElement is PasswordBox || DependencyObjectHelpers.FindParent <ContentDialog>(focusedElement) != null) { return; } base.Page_CharacterReceived(sender, args); AllView.Focus(FocusState.Keyboard); } } }
private void HandleRightClick(object sender, RoutedEventArgs e) { var rowPressed = DependencyObjectHelpers.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); if (rowPressed != null) { var objectPressed = ((IList <ListedItem>)AllView.ItemsSource).ElementAtOrDefault(rowPressed.GetIndex()); if (objectPressed == null) { return; } // Check if RightTapped row is currently selected if (!IsItemSelected) { if (!SelectedItems.Contains(objectPressed)) { ItemManipulationModel.SetSelectedItem(objectPressed); } } } }
private async void Properties_Loaded(object sender, RoutedEventArgs e) { AppSettings.ThemeModeChanged += AppSettings_ThemeModeChanged; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { // Set window size in the loaded event to prevent flickering if (WindowDecorationsHelper.IsWindowDecorationsAllowed) { appWindow.TitleBar.SetPreferredVisibility(AppWindowTitleBarVisibility.AlwaysHidden); appWindow.Frame.DragRegionVisuals.Add(TitleBarDragArea); crossIcon.Foreground = ThemeHelper.RootTheme switch { ElementTheme.Default => new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"]), ElementTheme.Light => new SolidColorBrush(Colors.Black), ElementTheme.Dark => new SolidColorBrush(Colors.White), _ => new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"]) }; var micaIsSupported = ApiInformation.IsMethodPresent("Windows.UI.Composition.Compositor", "TryCreateBlurredWallpaperBackdropBrush"); if (micaIsSupported) { micaBrush = new Brushes.MicaBrush(false); (micaBrush as Brushes.MicaBrush).SetAppWindow(appWindow); Frame.Background = micaBrush; } else { Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true); } var duration = new Duration(TimeSpan.FromMilliseconds(280)); RectHoverAnim = new Storyboard(); var RectHoverColorAnim = new ColorAnimation(); RectHoverColorAnim.Duration = duration; RectHoverColorAnim.From = Colors.Transparent; RectHoverColorAnim.To = Color.FromArgb(255, 232, 17, 35); RectHoverColorAnim.EasingFunction = new SineEase(); Storyboard.SetTarget(RectHoverColorAnim, CloseRect); Storyboard.SetTargetProperty(RectHoverColorAnim, "(Rectangle.Fill).(SolidColorBrush.Color)"); RectHoverAnim.Children.Add(RectHoverColorAnim); RectUnHoverAnim = new Storyboard(); var RectUnHoverColorAnim = new ColorAnimation(); RectUnHoverColorAnim.Duration = duration; RectUnHoverColorAnim.To = Colors.Transparent; RectUnHoverColorAnim.From = Color.FromArgb(255, 232, 17, 35); RectUnHoverColorAnim.EasingFunction = new SineEase(); Storyboard.SetTarget(RectUnHoverColorAnim, CloseRect); Storyboard.SetTargetProperty(RectUnHoverColorAnim, "(Rectangle.Fill).(SolidColorBrush.Color)"); RectUnHoverAnim.Children.Add(RectUnHoverColorAnim); CrossHoverAnim = new Storyboard(); var CrossHoverColorAnim = new ColorAnimation(); CrossHoverColorAnim.Duration = duration; CrossHoverColorAnim.From = ((SolidColorBrush)crossIcon.Foreground).Color; CrossHoverColorAnim.To = Colors.White; CrossHoverColorAnim.EasingFunction = new SineEase(); Storyboard.SetTarget(CrossHoverColorAnim, crossIcon); Storyboard.SetTargetProperty(CrossHoverColorAnim, "(PathIcon.Foreground).(SolidColorBrush.Color)"); CrossHoverAnim.Children.Add(CrossHoverColorAnim); CrossUnHoverAnim = new Storyboard(); var CrossUnHoverColorAnim = new ColorAnimation(); CrossUnHoverColorAnim.Duration = duration; CrossUnHoverColorAnim.To = ((SolidColorBrush)crossIcon.Foreground).Color; CrossUnHoverColorAnim.From = Colors.White; CrossUnHoverColorAnim.EasingFunction = new SineEase(); Storyboard.SetTarget(CrossUnHoverColorAnim, crossIcon); Storyboard.SetTargetProperty(CrossUnHoverColorAnim, "(PathIcon.Foreground).(SolidColorBrush.Color)"); CrossUnHoverAnim.Children.Add(CrossUnHoverColorAnim); } else { Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true); TitleBar = ApplicationView.GetForCurrentView().TitleBar; TitleBar.ButtonBackgroundColor = Colors.Transparent; TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; Window.Current.SetTitleBar(TitleBarDragArea); } await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => AppSettings.UpdateThemeElements.Execute(null)); } else { Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true); propertiesDialog = DependencyObjectHelpers.FindParent <ContentDialog>(this); propertiesDialog.Closed += PropertiesDialog_Closed; } }