随笔分类 - WPF
摘要:背景前端js需要连接后端wss服务 前端:js后端:c# - 控制台搭建wss服务器 步骤1 wss需要ssl认证,所以需要个证书,随便找一台linux的服务器(windows的话,自己安装下openssl即可),一般都有安装openssl的工具,利用它来生成一份证书 1、最好是cd到一个自定义目录
阅读全文
摘要:/// <summary> /// 返回时间差的总时长,以*天*时*分*秒的格式 /// </summary> /// <param name="startTime"></param> /// <param name="overTime"></param> /// <returns></return
阅读全文
摘要:btnQuery.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
阅读全文
摘要:Graphics currentGraphics = Graphics.FromHwnd(new WindowInteropHelper(Window.GetWindow(this)).Handle); double dpixRatio = currentGraphics.DpiX / 96;
阅读全文
摘要:场景是这样的,对象属性仅只有一个int的扩展字段,新建字段改动太大,所有需要糅合再一个字段里面标示多个属性... 0001 0000 0010 0000 16进制长这样...所以可以利用位来标记不同的属性,还有他们常说的高4位和低4位,例如上面,高4位就是0001,低4位就是0000 假如:高4位的
阅读全文
摘要:/// <summary> /// 辅助类 /// </summary> public class HostHelper { /// <summary> /// 尝试附加到托管调试器并断言在当前堆栈运行位置。 /// <para> /// 仅在DEBUG编译条件下生效。 /// </para> //
阅读全文
摘要:var data = new object[] { new { sn = SN, mac = Mac } }; var jobj = await Task.Run(() => { try { using (HttpClient client = new HttpClient()) { var url
阅读全文
摘要:new SolidColorBrush((Color)ColorConverter.ConvertFromString("#27212B"))
阅读全文
摘要:某些时候命令绑定可能会存在刷新不及时,往往需要点击一次程序才能激活,特此记录下解决方案 System.Windows.Input.CommandManager.InvalidateRequerySuggested();
阅读全文
摘要:1 <Window x:Class="CommandDemo.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com
阅读全文
摘要:1 /// <summary> 2 /// 将指定父级的下级索引元素,显示在视野下,使其可见 3 /// </summary> 4 /// <param name="control">父级</param> 5 /// <param name="i">需要可见的子集索引</param> 6 priva
阅读全文
摘要:某些时候,需要验证控件之间是否存在重叠的情况,可以借助 System.Windows.Rect.IntersectsWith 来验证;如果需要获取重叠的部分,则使用 System.Windows.Rect.Intersect 来实现! <Window x:Class="轨迹规划Demo.MainWi
阅读全文
摘要:场景:线程里面构建MVVM实体类,实体类包含 Brush 属性时,构建 SolidColorBrush 需要UI线程,否则会报 “必须在与 DependencyObject 相同的线程上创建 DependencySource” MVVM实体类 1 using System; 2 using Syst
阅读全文
摘要:private TreeViewItem FindTreeItem(TreeViewItem item, Func<TreeViewItem, bool> compare) { if (item == null) { return null; } var pd = compare?.Invoke(i
阅读全文
摘要:1、选中附件,右键生成操作选择 嵌入的资源,例如:handle.exe 2、FileUtil 1 using System.IO; 2 using System.Reflection; 3 4 namespace ResourceOccupancyHelp 5 { 6 public class Fi
阅读全文
摘要:/// <summary> /// 当前是否处于设计模式 /// </summary> bool IsInDesignMode { get { return (bool)DesignerProperties.IsInDesignModeProperty .GetMetadata(typeof(Dep
阅读全文
摘要:1 <StackPanel Margin="10"> 2 <TextBox Text="默认"></TextBox> 3 <TextBox InputMethod.PreferredImeState="On" InputMethod.PreferredImeConversionMode="Nativ
阅读全文
摘要:1 <UserControl x:Class="Zhaoxi.Controls.Loading" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microso
阅读全文
摘要:1 <Window x:Class="WpfApp3.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/win
阅读全文
摘要:添加右键上下文菜单后,点击后需要获取到源控件 1 private void MenuItem_Click(object sender, RoutedEventArgs e) 2 { 3 if (sender is MenuItem item && 4 item.Parent is ContextMe
阅读全文

浙公网安备 33010602011771号