一些使用go-fyne的笔记

界面交互 中文字体设置 查阅相关资料,有下面几种解决方案,下面来依次说明。 环境变量 可以通过指定 FYNE_FONT 环境变量来使用替代字体 使用字体bundle 安装fyne工具,使用下面的命令: go install fyne.io/fyne/v2/cmd/fyne@latest 准备好要使用的字体,我们这里使用miSans,使用下面命令 fyne bundle MiSans-Normal.ttf > bundle.go 然后创建一个theme package tinytheme import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/theme" "fyneHello/fontRes" "image/color" ) type ChineseTheme struct{} var _ fyne.Theme = (*ChineseTheme)(nil) func (m *ChineseTheme) Font(s fyne.TextStyle) fyne.Resource { return fontRes.ResourceMiSansTTF } func (*ChineseTheme) Color(n fyne.ThemeColorName, v fyne.ThemeVariant) color.Color { return theme.DefaultTheme().Color(n, v) } func (*ChineseTheme) Icon(n fyne.ThemeIconName) fyne.Resource { return theme.DefaultTheme().Icon(n) } func (*ChineseTheme) Size(n fyne....

January 11, 2024 · 11 min · czyt

一些windows定制的相关资源

脚本 移除Edge @echo off reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /v "NoRemove" /f >NUL 2>nul reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /v "experiment_control_labels" /f >NUL 2>nul reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdateDev" /v "AllowUninstall" /t REG_DWORD /d 1 /f >NUL 2>nul for /D %%I in ("%ProgramFiles(x86)%\Microsoft\Edge\Application\*") do ( if exist "%%I\Installer\setup.exe" ( echo Uninstalling Edge Chromium pushd "%%I\Installer" setup.exe --uninstall --msedge --force-uninstall --system-level --delete-profile popd ) ) msiexec /X{2BFF39DC-EFF0-355C-80CD-41D847013784} /qn /norestart set "value=MicrosoftEdgeAutoLaunch_.*" set "path=HKCU\Software\Microsoft\Windows\CurrentVersion\Run" for /f "tokens=1,*" %%A in ('reg query "%path%" /f "Microsoft" ^| findstr /R "%value%"') do ( reg delete "%path%" /v "%%A" /f ) del /q /f "%userprofile%\Desktop\Microsoft Edge....

September 20, 2023 · 1 min · czyt

Avalonia使用备忘

Avalonia 中的一些特性 Binding $parent 您可以使用$parent符号绑定到目标在逻辑上的父级: <Button DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" x:CompileBindings="False" Command="{Binding $parent[Window].DataContext.AddItem}">Add Item </Button> <Border Tag="Hello World!"> <TextBlock Text="{Binding $parent.Tag}"/> </Border> 也可以通过在$parent符号添加索引器绑定到父控件的父控件: <Border Tag="Hello World!"> <Border> <TextBlock Text="{Binding $parent[1].Tag}"/> </Border> </Border> 索引器从0开始,因此$parent[0]等同于$parent。 还可以按类型绑定到祖先: <Border Tag="Hello World!"> <Decorator> <TextBlock Text="{Binding $parent[Border].Tag}"/> </Decorator> </Border> 最后,您可以组合索引器和类型: <Border Tag="Hello World!"> <Border> <Decorator> <TextBlock Text="{Binding $parent[Border;1].Tag}"/> </Decorator> </Border> </Border> 如果需要在祖先类型中包含XAML命名空间,一般使用:字符: <local:MyControl Tag="Hello World!"> <Decorator> <TextBlock Text="{Binding $parent[local:MyControl].Tag}"/> </Decorator> </local:MyControl> #name 如果要绑定到另一个已命名控件的属性,可以使用以#字符为前缀的控件名称. <TextBox Name="other"> <!-- 绑定到命名为“other”控件的Text属性 --> <TextBlock Text="{Binding #other....

July 31, 2023 · 8 min · czyt

使用C#以编程方式切换Windows专注模式

缘起 最近需要以编程方式调用windows api实现windows10专注模式的切换,但是Google一圈,没有现成代码。找到的相关帖子要么是cpp的要么是rust的,而且是undocument的Windows api。 Csharp调用 以下是完整代码 public static class FocusAssistToogle { private const string NtdllDlDll = "ntdll.dll"; private const uint DataBufferSize = 4; private static readonly byte[] DisableDataBuf = { 0x00, 0x00, 0x00, 0x00 }; // 01仅优先通知 02 仅限闹钟 private static readonly byte[] EnableDataBuf = { 0x02, 0x00, 0x00, 0x00 }; [DllImport(NtdllDlDll, SetLastError = true)] private static extern int ZwUpdateWnfStateData( ref WnfSWnfStateName sWnfStateName, byte[] buffer, uint bufferSize, IntPtr previousStateData, IntPtr currentStateData, uint previousStateDataSize, uint currentStateDataSize); [StructLayout(LayoutKind....

July 24, 2023 · 2 min · czyt

浅谈windows默认Shell的替换

Windows XP时代 Xp时代提供的是通过注册表来自定义shell 设置所有用户的shell 注册表键HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell 设置当前用户的shell注册表键 HKEY_Current_User\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell 注册表键值类型 REG_SZ 值修改为你要自定义为shell的程序的完整路径。 在windows10下使用该技巧可能会出现黑屏的现象,参考stackoverflow的回答 Simply replacing the “explorer.exe” (HKLM\SOFTWARE\Microsoft\Window NT\Winlogon\Shell) with a custom app location provided a black screen. A much simpler way, and it works great, was to create a BATCH script to call the custom app through elevated powershell… powershell -nologo -noprofile -executionpolicy bypass -command "start-process -verb 'runas' -filepath <full path of custom app executable>" By replacing “explorer.exe” with this batch script I was able to successfully create a kiosk style lockdown under Windows 10 PRO with a non-UWP app....

August 31, 2022 · 2 min · czyt

Git小技巧

Windows下GIT的几个小技巧 记住git密码 使用下面命令可以设置记住git密码,但推荐使用ssh进行操作。 git config credential.helper store 设置换行符转换 在windows下开发时,迁出的代码是CRLF会导致编译的sh脚本不能正确执行: git config --global core.autocrlf false Git推送到多个服务器 要实现一次push到多个远程仓库 本机git仓库A https://aaaaa.git 要同步push的远程git仓库B https://bbbbb.git 通过git remote add添加 先使用git remote -v查看远程仓库的情况 ,然后添加一个git仓库 git remote add b https://bbbbb.git 再次查看远程仓库情况,如果需要push,则需要push两次 通过git remote set-url 添加 如果按上面添加过remote分支,需要先git remote rm b,使用下面命令添加即可。 git remote set-url --add a https://bbbbb.git 查看远程仓库情况,看看是否已经是两个push地址了 。这个只需push一次就行了 修改配置文件 打开 .git/config 找到 [remote “github”],添加对应的 url 即可,效果如下。这种方法其实和方法二是一样的。 [remote "a"] url = https://aaaaa.git fetch = +refs/heads/*:refs/remotes/a/* url = https://bbbbb.git 参考链接 ● 一个项目push到多个远程Git仓库 https://segmentfault....

June 17, 2022 · 2 min · czyt

grpc-golang windows环境搭建说明

下载protoc,打开链接 下载后将对应的文件解压到gopath的bin目录。 下载protoc的golang插件。下载地址 链接 下载后放在protoc的同级目录(需要改扩展名为exe) 测试,定义一个Proto syntax = "proto3"; option go_package = ".;hello"; package main; message String { string value = 1; } 然后执行命令 protoc hello.proto --go_out=. ,大功告成,生成的文件内容如下: // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.24.0-devel // protoc v3.12.3 // source: hello.proto package hello import ( proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date....

February 28, 2022 · 3 min · czyt

Rust安装及配置

下载rustup 从此处下载,如果你需要安装vs的cpp生成工具,可以在这个页面进行下载。 设置rustup镜像 字节提供的镜像 https://rsproxy.cn export RUSTUP_DIST_SERVER="https://rsproxy.cn" export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" 设置两个环境变量即可 设置环境变量 RUSTUP_DIST_SERVER (用于更新 toolchain) export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static 以及 RUSTUP_UPDATE_ROOT (用于更新 rustup) export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup 设置RUSTUP_HOME和CARGO_HOME可以实现自定义安装路径 crates.io 镜像 编辑 ~/.cargo/config ,这里使用的是中科大的镜像。 [source.crates-io] replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index" 或者使用字节的,参考官网文档 [source.crates-io] replace-with = 'rsproxy-sparse' [source.rsproxy] registry = "https://rsproxy.cn/crates.io-index" [source.rsproxy-sparse] registry = "sparse+https://rsproxy.cn/index/" [registries.rsproxy] index = "https://rsproxy.cn/crates.io-index" [net] git-fetch-with-cli = true 安装Rust Windows 安装rust即可。可以参考我的步骤,如果安装的是vs的cpp build tools,可以跳过。 Current installation options: default host triple: x86_64-pc-windows-msvc default toolchain: stable (default) profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation >2 I'm going to ask you the value of each of these installation options....

February 28, 2022 · 7 min · czyt