shaoshao
茶飘香,酒罢去,聚朋友,再回楼。
Your story may not have such a happy beginning,
but that doesn’t make who you are.
It’s the rest of your story,who you choose to be.
为天地立心,为生民立命,为往圣继绝学,为万世开太平。
你不是父母续集,子女的前传,朋友的番外。你不妨大胆点生活,不要因为没有掌声而丢掉梦想,不要因为看不清前路而轻易放弃。我相信你生来就是高山,而非溪流。亲爱的,勇敢而热烈的活着吧。
2023新春快乐!
2023新春快乐!
旧岁千般皆如意,新年万事定称心!
Arcpy 调用gp分析工具提示未获得许可
Arcpy 调用gp分析工具提示未获得许可
解决方法:调用gp分析工具前,添加如下代码
12if arcpy.CheckExtension("spatial") == "Available": arcpy.CheckOutExtension("spatial")
WPF全局未处理异常捕获
WPF全局未处理异常捕获事件订阅1System.Windows.Application.DispatcherUnhandledException += Application_DispatcherUnhandledException;
Application_DispatcherUnhandledException方法1234private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e){ ProMessageUtils.ShowDialog($"捕获未处理异常:{e.Exception.Message}\r\n{e.Exception.StackTrace}", "错误", System.Windows.MessageBoxButton.OK, System.Windows.Messa ...
C#开发工具类
CommonWPF UIUtils123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125public class UiUtils{ private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame); /// <summary> /// 刷新界面 /// </summary> public sta ...
Windows访问网络共享失败解决办法
Windows访问网络共享失败解决办法网络错误Windows 无法访问 192.168.200.121 请检查名称的拼写。否则,网络可能有问题。要尝试识别并解决网络问题,请单击“诊断”。查看详细信息——————————————————————————-诊断(D)———-取消—————————
解决:
12//cmdnet use \\地址 密码 /user:用户
C#实现程序卸载功能效果,删除程序自身
思路一通过调用 cmd 运行删除文件、目录命令实现。
code12345678910111213141516171819202122232425262728Dictionary<string,string> Uninstall_RemoveList = new Dictionary<string, string>() { { "d:\\test\\UninstallApp\\conf", "d" }, { "d:\\test\\Uninstall\\UninstallApp.exe", "f" }, { "d:\\test\\Uninstall\\UninstallApp.dll", "f" }, { "d:\\test\\UninstallApp\\log", "d" }};//因 ...
Windows注册表记录
Windows注册表记录
\HKEY_CLASSES_ROOT\SystemFileAssociations\ — 文件鼠标右键打开方式
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall — 卸载软件软件
C# 类型转换器 TypeConverter
自定义类型转换器1234567891011121314151617181920212223242526272829303132333435363738394041424344454647using System;using System.ComponentModel;using System.Globalization;using System.Drawing;public class PointConverter : TypeConverter { // Overrides the CanConvertFrom method of TypeConverter. // The ITypeDescriptorContext interface provides the context for the // conversion. Typically, this interface is used at design time to // provide information about the design-time container. public ...
C#中的“?” “?.” “??” “??=”运算符
一、 ? —— 可空类型修饰符引用类型能用空引用来表示一个不存在的值,但是值类型不能。例如:
12string str = null;int i = null;//编译报错
为了使值类型也能使用可空类型,就可以使用 ”?“ 来表示,表现形式为 “T?” 。例如:
12int i?;//表示可控的类型DataTime time?;//表示可空的时间
题外话:
T?是System.Nullable的缩写,更便于读取。属于泛型的一种。
二、?.不为null时执行后面的操作。例如:
123//两段代码等效Person.Name?.Person.Code;Person.Name = Person == null ? null : Person.Code;
三、?? —— 空合并运算符用于定义引用类型和可空类型的默认值。如果此运算符的左操作符不为Null,则此操作符返回左操作数,否则返回右操作数。
12//当a不为空时返回a,为null时返回bvar c = a ?? b;
四、??=C# 8.0 及更高版本中可使用空合并赋值运算符 ??=,该运算符仅在左侧操作数的求值结果为 ...
ArcGIS Pro 二次开发问题记录
ArcGIS Pro 二次开发问题记录Addin问题:菜单栏最后总有一个“加载项”页面,里面是所有的分组、按钮
解决:将 Config.daml 里面的各个 group 项的 appearsOnAddInTab 属性设置为 false 即可。
问题:加载项插件项目 与 管理配置项目 项目类型互换
解决:在项目文件(.csproj)中相应的添加/删除配置项:
123<PropertyGroup> <PackageType>Configuration</PackageType></PropertyGroup>
扩展:
加载项插件项目 -> 管理配置项目
添加 ConfigurationManager 实现类(修改加载界面、首页、关于页面,添加程序启动、退出事件等)
在 Config.daml 中添加:
123<Configuration> <ConfigurationManager className="ConfigurationManager实现类的类名"/> ...
Docker修改镜像、容器存储位置
Docker修改镜像、容器存储位置
先退出Docker Desktop
1234567891011121314151617181920212223242526272829Microsoft Windows [版本 10.0.19045.2486](c) Microsoft Corporation。保留所有权利。C:\Users\admin>wsl --list -v NAME STATE VERSION* docker-desktop-data Running 2 docker-desktop Stopped 2C:\Users\admin>wsl --shutdownC:\Users\admin>wsl --list -v NAME STATE VERSION* docker-desktop-data Stopped 2 docker-desktop St ...
WPF获取UI控件线程
WPF获取UI控件线程WPF中只能是UI线程才可以改变UI控件相关,当采用多线程工作时,可用以下代码获取UI线程进行操作:
12345//调用UI线程App.Current.Dispatcher.Invoke((Action)async delegate (){ Code...});
;
ArcGIS Pro Addin开发修改程序标题、加载界面、首页
ArcGIS Pro Addin开发修改程序标题、加载界面、首页新建 ArcGIS Pro 管理配置 项目
安装生成的配置项插件后,通过快捷方式启动Pro,快捷方式需要加参数“config:配置项名称”。
官方文档:配置管理器类 - ArcGIS Pro
ConfigurationManager Class Members
The following tables list the members exposed by ConfigurationManager.
Public Constructors
Name
Description
ConfigurationManager Constructor
Protected Properties
Name
Description
ApplicationName
Gets the new application name for the configuration.
Icon
Gets the new application icon for the configuration.
Run ...
C#获取系统目录
C#获取系统目录1Environment.GetFolderPath(Environment.SpecialFolder specialFolder)
枚举项
值
说明
AdminTools
48
用于存储各个用户的管理工具的文件系统目录。 Microsoft Management Console (MMC) 会将自定义的控制台保存在此目录中,并且此目录将随用户一起漫游。
ApplicationData
26
用作当前漫游用户的应用程序特定数据的公共储存库的目录。 漫游用户在网络上的多台计算机上工作。 漫游用户的配置文件保留在网络服务器上,并在用户登录时加载到系统中。
CDBurning
59
充当等待写入 CD 的文件的临时区域的文件系统目录。
CommonAdminTools
47
包含计算机所有用户的管理工具的文件系统目录。
CommonApplicationData
35
用作所有用户使用的应用程序特定数据的公共储存库的目录。
CommonDesktopDirectory
25
包含在所有用户桌面上出现的文件和文件夹的文件系统目录。
Com ...
C#判断程序是否为管理员权限启动
C# 判断程序是否为管理员权限启动123456bool IsAdministrator(){ WindowsIdentity current = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current); return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);}
}
C#创建快捷方式
C#创建快捷方式123456789101112131415161718192021222324252627282930//实例化WshShell对象WshShell shell = new WshShell();//通过该对象的 CreateShortcut 方法来创建 IWshShortcut 接口的实例对象IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//ShortCut.lnk");//设置快捷方式的目标所在的位置(源程序完整路径)shortcut.TargetPath = proInstallDir+ "\\bin\\ArcGISPro.exe";//应用程序的工作目录//当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。shortcut.WorkingDirectory = proIns ...
RegistryKey 读取注册表信息
RegistryKey 读取注册表信息RegistryKey读取注册表,明明看得到却读不到?
不要直接使用:
1var localMachineKey = Registry.LocalMachine;
而是使用如下与计算机位数相关的代码
12var useRegistryView = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32; var localMachineKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, useRegistryView);
);
SkiaSharp 初探
SkiaSharp 初探有个 .Net Framework 4.x 的项目需要升级到 .Net 6,升级过后发现 System.Drawing.dll 库相关功能模块会报错:
Could not load file or assembly ‘System.Drawing.Common, Version=7.0.0.0, Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51’.系统找不到指定文件。
因为 System.Drawing 对跨平台不支持,只支持Windows系统,.Net 6 貌似不再支持。
于是使用 SkiaSharp 代替。
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 ...
Neo4j初探
Neo4j 初探Create下边是一个巨大的代码块,其中包含由多个 CREATE 子句组成的单个 Cypher 查询语句。这将创建电影图形。
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 ...
C#读写config配置文件
C#读写config配置文件12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970public static class ConfigHelper{ public static LocalConfig _LocalConfig = null; static ConfigHelper() { _LocalConfig = new LocalConfig(); }}public class ConfigBase{ protected Configuration configObject; public ConfigBase(string configFilePath) { ExeConfigurationFileMap fileMap = new ExeCo ...
Git-报错 error: bad signature 0x00000000 fatal: index file corrupt
Git- 报错 error: bad signature 0x00000000 fatal: index file corrupt解决方案:
123rm -f .git/index git reset