private static void System_MouseDown(IconExtractorWindow wind, object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         if (e.ClickCount >= 2)
         {
             wind.WindowState = (wind.WindowState == WindowState.Normal) ? WindowState.Maximized : WindowState.Normal;
         }
         else
         {
             startPos = e.GetPosition(null);
         }
     }
     else if (e.ChangedButton == MouseButton.Right)
     {
         var    pos   = wind.PointToScreen(e.GetPosition(wind));
         IntPtr hWnd  = new System.Windows.Interop.WindowInteropHelper(wind).Handle;
         IntPtr hMenu = GetSystemMenu(hWnd, false);
         int    cmd   = TrackPopupMenu(hMenu, 0x100, (int)pos.X, (int)pos.Y, 0, hWnd, IntPtr.Zero);
         if (cmd > 0)
         {
             SendMessage(hWnd, 0x112, (IntPtr)cmd, IntPtr.Zero);
         }
     }
 }
        private static void System_MouseMove(IconExtractorWindow wind, object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (wind.WindowState == WindowState.Maximized && Math.Abs(startPos.Y - e.GetPosition(null).Y) > 2)
                {
                    var point = wind.PointToScreen(e.GetPosition(null));

                    wind.WindowState = WindowState.Normal;

                    wind.Left = point.X - (wind.ActualWidth / 2);
                    wind.Top  = point.Y - (wind.border.ActualHeight / 2);
                }

                wind.DragMove();
            }
        }