mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-23 19:49:17 +08:00
Temp commit? NOt sure if this breaks anything
This commit is contained in:
parent
9d8972201f
commit
e40f4b0c60
@ -0,0 +1,23 @@
|
||||
// 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;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace AdvancedPaste.Converters;
|
||||
|
||||
public sealed partial class InfoBadgeStyleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
<tkconverters:BoolToVisibilityConverter x:Name="BoolToVisibilityConverter" />
|
||||
<converters:CountToVisibilityConverter x:Name="countToVisibilityConverter" />
|
||||
<converters:PasteFormatsToHeightConverter x:Name="standardPasteFormatsToHeightConverter" />
|
||||
<converters:InfoBadgeStyleConverter x:Name="infoBadgeStyleConverter" />
|
||||
<converters:CountToDoubleConverter
|
||||
x:Name="customActionsToMinHeightConverter"
|
||||
ValueIfNonZero="40"
|
||||
@ -123,7 +124,7 @@
|
||||
<controls:PromptBox
|
||||
x:Name="CustomFormatTextBox"
|
||||
x:Uid="CustomFormatTextBox"
|
||||
Margin="8,4,8,0"
|
||||
Margin="8,4,8,-12"
|
||||
x:FieldModifier="public"
|
||||
TabIndex="0">
|
||||
<controls:PromptBox.Footer>
|
||||
@ -172,8 +173,8 @@
|
||||
</ToolTipService.ToolTip>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 5 0 5">Available formats :</TextBlock>
|
||||
<StackPanel Margin="-5 5 0 0" Orientation="Horizontal">
|
||||
<TextBlock Foreground="#CCCCCC" Style="{StaticResource CaptionTextBlockStyle}">Choose a paste action. Clipboard has: </TextBlock>
|
||||
<ItemsControl ItemsSource="{x:Bind ViewModel.AvailableFormatsText, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@ -182,7 +183,14 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Item1}" Margin="5,0" ToolTipService.ToolTip="{Binding Item2}" />
|
||||
<StackPanel Orientation="Horizontal" Margin="2 0 0 0">
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" Text="{Binding Item1}" ToolTipService.ToolTip="{Binding Item2}" />
|
||||
<InfoBadge Style="{ThemeResource InformationalDotInfoBadgeStyle}" Width="4" Height="4" Margin="-2 0 0 8">
|
||||
<InfoBadge.Visibility>
|
||||
<Binding Path="Item2" Converter="{StaticResource infoBadgeStyleConverter}" />
|
||||
</InfoBadge.Visibility>
|
||||
</InfoBadge>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
@ -175,6 +175,11 @@ namespace AdvancedPaste.Helpers
|
||||
internal static async Task<string> GetClipboardHtmlContent(DataPackageView clipboardData) =>
|
||||
clipboardData.Contains(StandardDataFormats.Html) ? await clipboardData.GetHtmlFormatAsync() : string.Empty;
|
||||
|
||||
internal static async Task<string> GetClipboardTextContent(DataPackageView clipboardData)
|
||||
{
|
||||
return clipboardData.Contains(StandardDataFormats.Text) ? await clipboardData.GetTextAsync() : string.Empty;
|
||||
}
|
||||
|
||||
internal static async Task<SoftwareBitmap> GetClipboardImageContentAsync(DataPackageView clipboardData)
|
||||
{
|
||||
using var stream = await GetClipboardImageStreamAsync(clipboardData);
|
||||
|
@ -230,6 +230,61 @@ namespace AdvancedPaste.ViewModels
|
||||
|
||||
ClipboardHistoryEnabled = IsClipboardHistoryEnabled();
|
||||
GeneratedResponses.Clear();
|
||||
await GenerateAvailableFormatsText();
|
||||
}
|
||||
|
||||
public async Task<bool> GenerateAvailableFormatsText()
|
||||
{
|
||||
AvailableFormatsText.Clear();
|
||||
|
||||
List<Tuple<ClipboardFormat, string>> formatQueryList = new()
|
||||
{
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Text, "Text,"),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Html, "Html,"),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Audio, "Audio,"),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Image, "Image,"),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.ImageFile, "ImageFile,"),
|
||||
};
|
||||
|
||||
ObservableCollection<Tuple<string, string>> returnList = new();
|
||||
|
||||
foreach (var formatQuery in formatQueryList)
|
||||
{
|
||||
if (AvailableClipboardFormats.HasFlag(formatQuery.Item1))
|
||||
{
|
||||
string presentedString = formatQuery.Item2;
|
||||
string tooltipContent = null;
|
||||
|
||||
if (formatQuery.Item1 == ClipboardFormat.Text)
|
||||
{
|
||||
tooltipContent = await ClipboardHelper.GetClipboardTextContent(ClipboardData);
|
||||
}
|
||||
else if (formatQuery.Item1 == ClipboardFormat.Html)
|
||||
{
|
||||
tooltipContent = await ClipboardHelper.GetClipboardHtmlContent(ClipboardData);
|
||||
}
|
||||
|
||||
returnList.Add(new Tuple<string, string>(formatQuery.Item2, tooltipContent));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove comma from last item
|
||||
if (returnList.Count > 0)
|
||||
{
|
||||
Tuple<string, string> lastItem = returnList.Last();
|
||||
if (!string.IsNullOrEmpty(lastItem.Item1))
|
||||
{
|
||||
lastItem = new Tuple<string, string>(lastItem.Item1.Substring(0, lastItem.Item1.Length - 1), lastItem.Item2);
|
||||
returnList[returnList.Count - 1] = lastItem;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in returnList)
|
||||
{
|
||||
AvailableFormatsText.Add(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// List to store generated responses
|
||||
@ -284,32 +339,7 @@ namespace AdvancedPaste.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Tuple<string, string>> AvailableFormatsText
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Tuple<ClipboardFormat, string>> formatQueryList = new()
|
||||
{
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Text, "Text "),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Html, "Html "),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Audio, "Audio "),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.Image, "Image "),
|
||||
new Tuple<ClipboardFormat, string>(ClipboardFormat.ImageFile, "ImageFile "),
|
||||
};
|
||||
|
||||
ObservableCollection<Tuple<string, string>> returnList = new();
|
||||
|
||||
foreach (var formatQuery in formatQueryList)
|
||||
{
|
||||
if (AvailableClipboardFormats.HasFlag(formatQuery.Item1))
|
||||
{
|
||||
returnList.Add(new Tuple<string, string>(formatQuery.Item2, "Hello world"));
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
public ObservableCollection<Tuple<string, string>> AvailableFormatsText { get; } = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private string _customFormatResult;
|
||||
|
Loading…
Reference in New Issue
Block a user