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 WinRT; | |
public void SetOwnerWindow(StoreContext context, Window window) | |
{ | |
var handle = new WindowInteropHelper(window).Handle; | |
var initWindow = context.As<IInitializeWithWindow>(); | |
initWindow.Initialize(handle); | |
} |
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
[ComImport] | |
[Guid("3E68D4BD-7135-4D10-8018-9FB6D9F33FA1")] | |
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
public interface IInitializeWithWindow | |
{ | |
void Initialize(IntPtr hwnd); | |
} | |
public void SetOwnerWindow(StoreContext context, Window window) | |
{ |
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.Net.NetworkInformation; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Interop; | |
using Windows.Services.Store; | |
using WinRT.Interop; | |
internal static class StoreHelper | |
{ |
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
[ValueConversion(typeof(bool), typeof(Brush))] | |
public class BooleanToBrushConverter : IValueConverter | |
{ | |
public Brush TrueBrush { get; set; } = Brushes.Gray; | |
public Brush FalseBrush { get; set; } = Brushes.Gray; | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return value switch | |
{ |
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; | |
public class WindowCenterMover | |
{ | |
#region Win32 | |
[DllImport("User32.dll")] |
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.Forms; | |
public class NotifyIconHolder | |
{ | |
public event EventHandler<Point>? MouseRightClick; | |
public event EventHandler<Point>? MouseLeftClick; | |
public event EventHandler<Point>? MouseDoubleClick; |
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 static class PopupHelper | |
{ | |
[DllImport("User32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); | |
[StructLayout(LayoutKind.Sequential)] | |
private struct RECT | |
{ | |
public int Left; |
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.Globalization; | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
foreach (var c in CultureInfo.GetCultures(CultureTypes.AllCultures)) | |
Console.WriteLine(c); |
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.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Media; | |
public static class TreeViewHelper | |
{ | |
public static double? GetLeftMargin(DependencyObject obj) | |
{ | |
return (double?)obj.GetValue(LeftMarginProperty); | |
} |