mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
I broke it
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Settings;
|
using Microsoft.CmdPal.UI.ViewModels.Settings;
|
||||||
|
|
||||||
@@ -84,6 +85,12 @@ public partial class DockBandSettingsViewModel : ObservableObject
|
|||||||
set => ShowLabels = (ShowLabelsOption)value;
|
set => ShowLabels = (ShowLabelsOption)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void Unpin()
|
||||||
|
{
|
||||||
|
PinSideIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private DockPinSide PinSide
|
private DockPinSide PinSide
|
||||||
{
|
{
|
||||||
get => _pinSide;
|
get => _pinSide;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
x:Class="Microsoft.CmdPal.UI.Controls.DockEditor"
|
x:Class="Microsoft.CmdPal.UI.Controls.DockEditor"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
|
||||||
|
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:dockVm="using:Microsoft.CmdPal.UI.ViewModels.Dock"
|
xmlns:dockVm="using:Microsoft.CmdPal.UI.ViewModels.Dock"
|
||||||
xmlns:helpers="using:Microsoft.CmdPal.UI.Helpers"
|
xmlns:helpers="using:Microsoft.CmdPal.UI.Helpers"
|
||||||
@@ -81,70 +83,74 @@
|
|||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="4"
|
CornerRadius="4"
|
||||||
ToolTipService.ToolTip="{x:Bind Title}">
|
ToolTipService.ToolTip="{x:Bind Title}">
|
||||||
<Button Style="{StaticResource SubtleButtonStyle}">
|
<FlyoutBase.AttachedFlyout>
|
||||||
<Button.Flyout>
|
<Flyout Placement="Bottom">
|
||||||
<Flyout Placement="Bottom">
|
<Grid Width="280">
|
||||||
<Grid Width="280">
|
<Grid.RowDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
</Grid.RowDefinitions>
|
||||||
</Grid.RowDefinitions>
|
<StackPanel
|
||||||
<StackPanel
|
Margin="0,0,0,16"
|
||||||
Margin="0,0,0,16"
|
Orientation="Horizontal"
|
||||||
Orientation="Horizontal"
|
Spacing="8">
|
||||||
Spacing="8">
|
<local:IconBox
|
||||||
<local:IconBox
|
x:Name="OptionsFlyoutIcons"
|
||||||
x:Name="OptionsFlyoutIcons"
|
Width="24"
|
||||||
Width="24"
|
Height="24"
|
||||||
Height="24"
|
HorizontalAlignment="Center"
|
||||||
HorizontalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
SourceKey="{x:Bind Icon, Mode=OneWay}"
|
||||||
SourceKey="{x:Bind Icon, Mode=OneWay}"
|
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
|
||||||
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
|
<TextBlock
|
||||||
<TextBlock
|
x:Name="OptionsFlyoutTitle"
|
||||||
x:Name="OptionsFlyoutTitle"
|
VerticalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
Text="{x:Bind Title, Mode=OneWay}" />
|
||||||
Text="{x:Bind Title, Mode=OneWay}" />
|
</StackPanel>
|
||||||
</StackPanel>
|
<StackPanel Grid.Row="1" Margin="0,0,0,16">
|
||||||
<StackPanel Grid.Row="1" Margin="0,0,0,16">
|
<TextBlock
|
||||||
<TextBlock
|
Margin="0,0,0,8"
|
||||||
Margin="0,0,0,8"
|
FontSize="12"
|
||||||
FontSize="12"
|
Text="Show labels" />
|
||||||
Text="Show labels" />
|
<ComboBox
|
||||||
<ComboBox
|
x:Name="ShowLabelsComboBox"
|
||||||
x:Name="ShowLabelsComboBox"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
SelectedIndex="{x:Bind ShowLabelsIndex, Mode=TwoWay}">
|
|
||||||
<ComboBoxItem Content="Default" />
|
|
||||||
<ComboBoxItem Content="Show" />
|
|
||||||
<ComboBoxItem Content="Hide" />
|
|
||||||
</ComboBox>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Border
|
|
||||||
Grid.Row="2"
|
|
||||||
Height="1"
|
|
||||||
Margin="0,0,0,16"
|
|
||||||
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
|
||||||
<Button
|
|
||||||
Grid.Row="3"
|
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Click="UnpinButton_Click"
|
SelectedIndex="{x:Bind ShowLabelsIndex, Mode=TwoWay}">
|
||||||
Content="Unpin from dock" />
|
<ComboBoxItem Content="Default" />
|
||||||
</Grid>
|
<ComboBoxItem Content="Show" />
|
||||||
</Flyout>
|
<ComboBoxItem Content="Hide" />
|
||||||
</Button.Flyout>
|
</ComboBox>
|
||||||
<local:IconBox
|
</StackPanel>
|
||||||
Width="24"
|
|
||||||
Height="24"
|
<Border
|
||||||
HorizontalAlignment="Center"
|
Grid.Row="2"
|
||||||
VerticalAlignment="Center"
|
Height="1"
|
||||||
SourceKey="{x:Bind Icon, Mode=OneWay}"
|
Margin="0,0,0,16"
|
||||||
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
|
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
||||||
</Button>
|
<Button
|
||||||
|
Grid.Row="3"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Click="UnpinButton_Click"
|
||||||
|
Command="{x:Bind UnpinCommand}"
|
||||||
|
Content="Unpin from dock" />
|
||||||
|
</Grid>
|
||||||
|
</Flyout>
|
||||||
|
</FlyoutBase.AttachedFlyout>
|
||||||
|
<Interactivity:Interaction.Behaviors>
|
||||||
|
<Core:EventTriggerBehavior EventName="Tapped">
|
||||||
|
<helpers:OpenFlyoutAction />
|
||||||
|
</Core:EventTriggerBehavior>
|
||||||
|
</Interactivity:Interaction.Behaviors>
|
||||||
|
<local:IconBox
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
SourceKey="{x:Bind Icon, Mode=OneWay}"
|
||||||
|
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
@@ -296,7 +302,7 @@
|
|||||||
DragItemsCompleted="ListView_DragItemsCompleted"
|
DragItemsCompleted="ListView_DragItemsCompleted"
|
||||||
DragItemsStarting="ListView_DragItemsStarting"
|
DragItemsStarting="ListView_DragItemsStarting"
|
||||||
DragOver="ListView_DragOver"
|
DragOver="ListView_DragOver"
|
||||||
Drop="EndListView_Drop"
|
Drop="StartListView_Drop"
|
||||||
IsItemClickEnabled="False"
|
IsItemClickEnabled="False"
|
||||||
ItemContainerStyle="{StaticResource DockEditorListViewItemStyle}"
|
ItemContainerStyle="{StaticResource DockEditorListViewItemStyle}"
|
||||||
ItemTemplate="{StaticResource DockBandItemTemplate}"
|
ItemTemplate="{StaticResource DockBandItemTemplate}"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public sealed partial class DockEditor : UserControl
|
|||||||
private DockBandSettingsViewModel? _draggedItem;
|
private DockBandSettingsViewModel? _draggedItem;
|
||||||
private ObservableCollection<DockBandSettingsViewModel>? _sourceCollection;
|
private ObservableCollection<DockBandSettingsViewModel>? _sourceCollection;
|
||||||
private DockEditorPinArea _targetArea;
|
private DockEditorPinArea _targetArea;
|
||||||
private DockBandSettingsViewModel? _currentContextItem;
|
|
||||||
|
|
||||||
public Orientation Orientation
|
public Orientation Orientation
|
||||||
{
|
{
|
||||||
@@ -206,31 +205,19 @@ public sealed partial class DockEditor : UserControl
|
|||||||
|
|
||||||
private void UnpinButton_Click(object sender, RoutedEventArgs e)
|
private void UnpinButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentContextItem == null)
|
if (sender is Button btn && btn.DataContext is DockBandSettingsViewModel contextItem)
|
||||||
{
|
{
|
||||||
return;
|
// Remove from all UI collections
|
||||||
|
StartItems.Remove(contextItem);
|
||||||
|
CenterItems.Remove(contextItem);
|
||||||
|
EndItems.Remove(contextItem);
|
||||||
|
|
||||||
|
// Refresh available items
|
||||||
|
RefreshAvailableItems();
|
||||||
|
|
||||||
|
// Close the flyout
|
||||||
|
CloseFlyoutFromSender(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove from all UI collections
|
|
||||||
StartItems.Remove(_currentContextItem);
|
|
||||||
CenterItems.Remove(_currentContextItem);
|
|
||||||
EndItems.Remove(_currentContextItem);
|
|
||||||
|
|
||||||
// Set pin side to None
|
|
||||||
_currentContextItem.PinSideIndex = 0;
|
|
||||||
|
|
||||||
// Refresh available items
|
|
||||||
RefreshAvailableItems();
|
|
||||||
|
|
||||||
_currentContextItem = null;
|
|
||||||
|
|
||||||
// Close the flyout
|
|
||||||
CloseFlyoutFromSender(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DockItemOptionsFlyout_Closed(object sender, object e)
|
|
||||||
{
|
|
||||||
_currentContextItem = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
private void ListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
||||||
|
|||||||
@@ -41,14 +41,12 @@
|
|||||||
Style="{StaticResource TaskBarButtonStyle}"
|
Style="{StaticResource TaskBarButtonStyle}"
|
||||||
Tapped="BandItem_Tapped"
|
Tapped="BandItem_Tapped"
|
||||||
ToolTipService.ToolTip="{x:Bind Tooltip, Mode=OneWay}">
|
ToolTipService.ToolTip="{x:Bind Tooltip, Mode=OneWay}">
|
||||||
|
|
||||||
<Grid AutomationProperties.Name="{x:Bind Title, Mode=OneWay}" Background="Transparent">
|
<Grid AutomationProperties.Name="{x:Bind Title, Mode=OneWay}" Background="Transparent">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
|
using Microsoft.Xaml.Interactivity;
|
||||||
|
|
||||||
|
namespace Microsoft.CmdPal.UI.Helpers;
|
||||||
|
|
||||||
|
public class OpenFlyoutAction : DependencyObject, IAction
|
||||||
|
{
|
||||||
|
public object? Execute(object sender, object parameter)
|
||||||
|
{
|
||||||
|
FlyoutBase.ShowAttachedFlyout(TargetObject ?? (FrameworkElement)sender);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Control TargetObject
|
||||||
|
{
|
||||||
|
get { return (Control)GetValue(TargetObjectProperty); }
|
||||||
|
set { SetValue(TargetObjectProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty TargetObjectProperty =
|
||||||
|
DependencyProperty.Register(nameof(TargetObject), typeof(Control), typeof(OpenFlyoutAction), new PropertyMetadata(null));
|
||||||
|
}
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
<!-- Bands Section -->
|
<!-- Bands Section -->
|
||||||
<TextBlock x:Uid="DockBandsSettingsHeader" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />
|
<TextBlock x:Uid="DockBandsSettingsHeader" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />
|
||||||
<Grid BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1">
|
<Grid BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1">
|
||||||
<cpControls:DockEditor Height="148" DockItems="{x:Bind AllDockBandItems, Mode=OneWay}" />
|
<cpControls:DockEditor Height="56" DockItems="{x:Bind AllDockBandItems, Mode=OneWay}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!--<ItemsRepeater ItemsSource="{x:Bind AllDockBandItems, Mode=OneWay}">
|
<!--<ItemsRepeater ItemsSource="{x:Bind AllDockBandItems, Mode=OneWay}">
|
||||||
|
|||||||
Reference in New Issue
Block a user