交互优化, 断网更新弹框删除,图标显示优化,待办任务bug修复

This commit is contained in:
liufei
2021-07-27 16:53:28 +08:00
parent 15a214aad0
commit 94f32fdb15
19 changed files with 916 additions and 253 deletions

95
Util/IconHelper.cs Normal file
View File

@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace GeekDesk.Util
{
public class IconHelper
{
[DllImport("Shell32.dll")]
private static extern IntPtr SHGetFileInfo
(
string pszPath, //һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȡ<D2AA><C8A1><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><E5A1A3><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ע[1]
uint dwFileAttributes,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>uFlags<67>а<EFBFBD><D0B0><EFBFBD>SHGFI_USEFILEATTRIBUTES<45><53>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(һ<>ʹ<E3B2BB><CAB9>)<29><><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><E6B5B5>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>ϵͳ<CFB5>ȡ<EFBFBD>
out SHFILEINFO psfi,
uint cbfileInfo,//<2F>򵥵ظ<F2B5A5B5><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijߴ
SHGFI uFlags//<2F><><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF>ܵı<DCB5>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD>Ԧ<EFBFBD><D4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʵ<EFBFBD>ʵصõ<D8B5><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2>
);
[StructLayout(LayoutKind.Sequential)]
private struct SHFILEINFO
{
public SHFILEINFO(bool b)
{
hIcon = IntPtr.Zero; iIcon = 0; dwAttributes = 0; szDisplayName = ""; szTypeName = "";
}
public IntPtr hIcon;//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int iIcon;//ϵͳͼ<CDB3><CDBC><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public uint dwAttributes; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[MarshalAs(UnmanagedType.LPStr, SizeConst = 260)]
public string szDisplayName;//<2F>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD> <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>256<35><36>ANSI<53><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷<EFBFBD><CCB7><EFBFBD>X:\<5C><>3<EFBFBD>ֽڣ<D6BD>259<35>ֽڣ<D6BD><DAA3>ټ<EFBFBD><D9BC>Ͻ<EFBFBD><CFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ֽڣ<D6BD><DAA3><EFBFBD>260
[MarshalAs(UnmanagedType.LPStr, SizeConst = 80)]
public string szTypeName;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̶<EFBFBD>80<38>ֽ<EFBFBD>
};
private enum SHGFI
{
SmallIcon = 0x00000001,
LargeIcon = 0x00000000,
Icon = 0x00000100,
DisplayName = 0x00000200,//Retrieve the display name for the file, which is the name as it appears in Windows Explorer. The name is copied to the szDisplayName member of the structure specified in psfi. The returned display name uses the long file name, if there is one, rather than the 8.3 form of the file name. Note that the display name can be affected by settings such as whether extensions are shown.
Typename = 0x00000400, //Retrieve the string that describes the file's type. The string is copied to the szTypeName member of the structure specified in psfi.
SysIconIndex = 0x00004000, //Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return value is a handle to the system image list. Only those images whose indices are successfully copied to iIcon are valid. Attempting to access other images in the system image list will result in undefined behavior.
UseFileAttributes = 0x00000010 //Indicates that the function should not attempt to access the file specified by pszPath. Rather, it should act as if the file specified by pszPath exists with the file attributes passed in dwFileAttributes. This flag cannot be combined with the SHGFI_ATTRIBUTES, SHGFI_EXETYPE, or SHGFI_PIDL flags.
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>õ<EFBFBD>ϵͳ<CFB5><CDB3>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
/// </summary>
/// <param name="fileName"><3E>ļ<EFBFBD><C4BC><EFBFBD>(<28>磺win.rar;setup.exe;temp.txt)</param>
/// <param name="largeIcon">ͼ<><CDBC><EFBFBD>Ĵ<EFBFBD>С</param>
/// <returns></returns>
public static Icon GetFileIcon(string fileName, bool largeIcon)
{
SHFILEINFO info = new SHFILEINFO(true);
int cbFileInfo = Marshal.SizeOf(info);
SHGFI flags;
if (largeIcon)
flags = SHGFI.Icon | SHGFI.LargeIcon | SHGFI.UseFileAttributes;
else
flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes;
IntPtr IconIntPtr = SHGetFileInfo(fileName, 256, out info, (uint)cbFileInfo, flags);
if (IconIntPtr.Equals(IntPtr.Zero))
return null;
return Icon.FromHandle(info.hIcon);
}
/// <summary>
/// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ͼ<EFBFBD><CDBC>
/// </summary>
/// <returns>ͼ<><CDBC></returns>
public static Icon GetDirectoryIcon(string path, bool largeIcon)
{
SHFILEINFO _SHFILEINFO = new SHFILEINFO();
int cbFileInfo = Marshal.SizeOf(_SHFILEINFO);
SHGFI flags;
if (largeIcon)
flags = SHGFI.Icon | SHGFI.LargeIcon;
else
flags = SHGFI.Icon | SHGFI.SmallIcon;
IntPtr IconIntPtr = SHGetFileInfo(path, 256, out _SHFILEINFO, (uint)cbFileInfo, flags);
if (IconIntPtr.Equals(IntPtr.Zero))
return null;
Icon _Icon = Icon.FromHandle(_SHFILEINFO.hIcon);
return _Icon;
}
}
}