This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.IO; | |
| using System.Windows.Media.Imaging; | |
| using SkiaSharp; | |
| public static class SKHelper | |
| { | |
| public static BitmapImage Convert(string filePath) | |
| { | |
| using SKImage image = SKImage.FromEncodedData(filePath); | |
| using SKData encoded = image.Encode(); // PNG format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using System.Collections.Specialized; | |
| using System.ComponentModel; | |
| using System.Windows.Controls; | |
| using System.Windows.Controls.Primitives; | |
| using Microsoft.Xaml.Behaviors; | |
| public class ItemsControlBehavior : Behavior<ItemsControl> | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading.Tasks; | |
| using System.Windows.Interop; | |
| using Windows.Storage.Pickers; | |
| public static async Task<string?> OpenFileDialog(System.Windows.Window window) | |
| { | |
| var picker = new FileOpenPicker() | |
| { | |
| ViewMode = PickerViewMode.Thumbnail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Window x:Class="WpfApp.MainWindow" | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| Title="MainWindow" | |
| Width="400" Height="200"> | |
| <Window.Resources> | |
| <Style x:Key="RoundStyle" TargetType="{x:Type Button}"> | |
| <Setter Property="Width" Value="100"/> | |
| <Setter Property="Height" Value="100"/> | |
| <Setter Property="Foreground"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Diagnostics.CodeAnalysis; | |
| using System.Windows; | |
| using System.Windows.Media; | |
| public static class DependencyObjectExtensions | |
| { | |
| public static bool TryFindDescendant<T>(this DependencyObject reference, [NotNullWhen(true)] out T? descendant) where T : DependencyObject | |
| { | |
| var queue = new Queue<DependencyObject>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Diagnostics; | |
| using System.Runtime.InteropServices; | |
| internal static class TaskbarHelper | |
| { | |
| [DllImport("user32.dll", CharSet = CharSet.Unicode)] | |
| extern static IntPtr FindWindow( | |
| [MarshalAs(UnmanagedType.LPWStr), In] string lpClassName, | |
| [MarshalAs(UnmanagedType.LPWStr), In] string? lpWindowName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public partial class MainWindow : Window | |
| { | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| this.Loaded += OnLoaded; | |
| } | |
| private async void OnLoaded(object sender, RoutedEventArgs e) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Management; | |
| public static class MonitorHelper | |
| { | |
| public static IEnumerable<MonitorConnection> EnumerateMonitorConnections() | |
| { | |
| var @class = new ManagementClass(@"root\wmi:WmiMonitorConnectionParams"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using System.Globalization; | |
| using System.Windows.Data; | |
| public class CollectionToBooleanConverter : IValueConverter | |
| { | |
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
| { | |
| if (value is IEnumerable collection) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Runtime.InteropServices; | |
| using System.Windows; | |
| using System.Windows.Interop; | |
| using System.Windows.Media; | |
| public static class WindowHelper | |
| { | |
| public static Point PointToScreen(Visual visual, Point point) | |
| { |