예제 #1
0
 private static UIElement LoadNativeResource(NativeIconResource resource)
 {
     return(new Image
     {
         Source = Imaging.CreateBitmapSourceFromHIcon(resource.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
     });
 }
        internal void Update()
        {
            var icon         = nativeMethods.GetWindowIcon(Handle);
            var iconChanged  = icon != IntPtr.Zero && (!(Icon is NativeIconResource) || Icon is NativeIconResource r && r.Handle != icon);
            var title        = nativeMethods.GetWindowTitle(Handle);
            var titleChanged = Title?.Equals(title, StringComparison.Ordinal) != true;

            if (iconChanged)
            {
                Icon = new NativeIconResource {
                    Handle = icon
                };
                IconChanged?.Invoke(Icon);
            }

            if (titleChanged)
            {
                Title = title;
                TitleChanged?.Invoke(title);
            }
        }