当前位置: 首页 > news >正文

C# Avalonia 20 - WindowsMenu- TransparentWithShapes

TransparentWithShapes.axaml代码

<Window xmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"Width="210" Height="170"x:Class="AvaloniaUI.TransparentWithShapes"Title="TransparentWithShapes"SystemDecorations="None"TransparencyLevelHint="Transparent"Background="Transparent"><Grid x:Name="root"><!-- 这里的 Path 既画边框/填充,也会用于 Clip  --><Path x:Name="shapePath"Stroke="DarkGray"StrokeThickness="1"Stretch="None"><Path.Fill><LinearGradientBrush StartPoint="20%,0%" EndPoint="80%,100%"><GradientStop Color="White" Offset="0"/><GradientStop Color="White" Offset="0.45"/><GradientStop Color="LightBlue" Offset="0.9"/><GradientStop Color="Gray" Offset="1"/></LinearGradientBrush></Path.Fill><Path.Data><PathGeometry><PathFigure StartPoint="20,0" IsClosed="True"><LineSegment Point="140,0"/><ArcSegment Point="160,20" Size="20,20" SweepDirection="Clockwise"/><LineSegment Point="160,60"/><ArcSegment Point="140,80" Size="20,20" SweepDirection="Clockwise"/><LineSegment Point="70,80"/><LineSegment Point="70,130"/><LineSegment Point="40,80"/><LineSegment Point="20,80"/><ArcSegment Point="0,60" Size="20,20" SweepDirection="Clockwise"/><LineSegment Point="0,20"/><ArcSegment Point="20,0" Size="20,20" SweepDirection="Clockwise"/></PathFigure></PathGeometry></Path.Data><Path.RenderTransform><ScaleTransform ScaleX="1.3" ScaleY="1.3"/></Path.RenderTransform></Path><StackPanel Margin="5"><Button HorizontalAlignment="Right"Margin="0,5,10,0"Click="cmdClose_Click">x</Button><TextBlock TextWrapping="Wrap"FontSize="15"HorizontalAlignment="Center"PointerPressed="window_PointerPressed">This is a balloon-shaped window.</TextBlock></StackPanel></Grid>
</Window>

TransparentWithShapes.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media;namespace AvaloniaUI;public partial class TransparentWithShapes : Window
{public TransparentWithShapes(){InitializeComponent();ApplyClip();}private void ApplyClip(){if (shapePath.Data is not Geometry geometry)return;Geometry clip;clip = Geometry.Parse(geometry.ToString() ?? "");if (shapePath.RenderTransform != null){clip.Transform = new MatrixTransform(shapePath.RenderTransform.Value);}root.Clip = clip;}private void cmdClose_Click(object? sender, RoutedEventArgs e){Close();}private void window_PointerPressed(object? sender, PointerPressedEventArgs e){if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)BeginMoveDrag(e);}
}

运行效果

image

 

http://www.jsqmd.com/news/515924/

相关文章:

  • AT24C02 EEPROM嵌入式驱动与I²C软件模拟实现
  • Verilog状态机设计避坑指南:101序列检测中的重叠与非重叠问题
  • MedGemma 1.5镜像免配置:自动检测GPU并加载最优推理后端
  • openclaw+Nunchaku FLUX.1-dev:面向开发者的文生图模型集成开发指南
  • 基于PI+重复控制的APF有源电力滤波器谐波抑制策略及仿真过程文献指南——文献为操作工具资料解...
  • 用动画+代码彻底搞懂插入排序:从原理到实战(附Python/Java实现)
  • Qwen-Image RTX4090D镜像实战案例:制造业BOM表截图结构化提取与物料关联
  • CoPaw创意图像描述生成:为无障碍设计提供精准Alt文本
  • Flask Session安全实战:如何防止你的SECRET_KEY被内存窃取(附防护代码)
  • Janus-Pro-7B在工业软件中的应用探索:与SolidWorks协作进行设计说明生成
  • Apache SeaTunnel二次开发实战:从任务提交到指标监控的全流程指南
  • YOLOv10快速部署秘籍:使用官方镜像避开所有环境坑
  • Atlas OEM模块嵌入式驱动开发:EC/DO传感器UART通信实现
  • 从环境配置到模型导出:星图AI训练PETRV2-BEV的完整流程
  • CATIA二次开发(CAA)实战:利用CATIDescendants精准遍历与筛选几何图形集
  • OpenClaw技能扩展实战:GLM-4.7-Flash驱动Markdown文章自动发布
  • 【LDLTS解析】从原理到实践:高分辨率半导体缺陷表征新范式
  • Ollama部署LFM2.5-1.2B-Thinking:Ubuntu系统下的完整部署步骤
  • SenseVoice-small-onnx ONNX量化模型部署实操:Windows/Linux/macOS跨平台适配
  • Z-Image-Turbo WebUI使用技巧:如何写出让AI听话的壁纸提示词
  • OpenClaw排错大全:GLM-4.7-Flash连接失败7种解法
  • Nanbeige 4.1-3B效果展示:支持Markdown表格渲染的像素化数据报告
  • Pixel Dimension Fissioner惊艳效果展示:10组零样本维度手稿真实生成对比
  • ComfyUI-Manager启动控制核心:prestartup_script.py深度解析
  • gemma-3-12b-it惊艳效果:水墨画→艺术流派判断+画家风格模仿文案创作
  • 如何通过WeChatMsg实现数据自主权?——本地化管理微信聊天记录的终极指南
  • Vue3打印解决方案:从核心价值到实战落地的全方位指南
  • 5分钟免费解锁付费墙:2024年浏览器扩展终极指南
  • 基于LaTeX的万物识别技术文档自动生成系统
  • 实时口罩检测在智慧城市中的应用:多摄像头联动方案