lindexi

林德熙 - 微软最具价值专家和 .NET 基金会成员

林德熙

C# dotnet 使用 OpenXml 解析 PPT 文件

在 2013 微软开源了 OpenXml 解析库,在微软的 PPTX 文档,使用的文档格式就是国际规范的 OpenXml 格式。这个格式有很多版本,详细请看百度。因为演示文稿使用的是 OpenXml 在 .NET 开发可以非常简单将 PowerPoint 文档进行解析,大概只需要两句话

dotnet 动态代理魔法书

看到标题的小伙伴是不是想知道什么是魔法书,如果你需要写一段代码,这段代码是在做神奇的业务,只有你查询到了魔法书你才能找到这个对象,同时你还需要实现自己的接口,通过自己实现的接口调用才能用到有趣的方法

Roslyn 理解 msbuild 的清理过程

在开发的时候,小伙伴会使用右击解决方案,点击清理解决方案。在这个按钮点击的背后 msbuild 做了什么?为什么很多时候的清理之后还存在一堆文件?如何让自己想的 Target 也支持清理

dotnet 获取指定进程的输入命令行

本文告诉大家如何在 dotnet 获取指定的进程的命令行参数

dotnet 新项目格式与对应框架预定义的宏

在 sdk style 的项目格式支持使用多框架开发,此时需要在代码里面通过宏判断,在编译的时候执行不同的代码。本文告诉大家在框架里面对应的预定义的条件编译符有哪些

win10 uwp win2d 特效

本文告诉大家 win2d 里面的特效

dotnet 给MatterMost订阅RSS博客

其实MatterMost是有插件可以用来订阅RSS博客的,但是这个订阅插件需要一个个网址输入,而不是一次性输入很多个,于是我去就自己写了一个控制台程序做订阅

dotnet OpenXML 文本 ParagraphProperties 的属性作用

本文收集 a:pPr 段落属性 ParagraphProperties 的属性的作用

WPF 延迟加载

参见:http://www.cnblogs.com/wpfworld/p/3181014.html

WPF shows that some windows in multithreading will be locked in the PenThreadWorker constructor when the application starts

Problem description: WPF will initialize pen thread when the window initializing. But I find the window may be locked in PenThreadWorker constructor. The UnsafeNativeMethods.CreateResetEvent will lock the thread.

Actual behavior: I use multithreading to create some windows by this code and maybe the thread be locked in PenThreadWorker constructor. The Demo code

    public partial class App : Application
    {
        /// <inheritdoc />
        protected override void OnStartup(StartupEventArgs e)
        {
            var thread = new Thread(() =>
            {
                var mainWindow = new MainWindow();
                mainWindow.Show();
                Dispatcher.Run();
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            base.OnStartup(e);
        }
    }

The step

  1. Run the code
  2. Use the VisualStudio to suspend the application Maybe you can find the application only create a Stylus Input thread and show only a main window and the other main window and the thread be locked in PenThreadWorker constructor and the window can not show Why I need multithreading to show the windows? I need the splash window to show the welcome page and then I should show the main window in other thread to do the bussiness code and I should close the splash window when the main window showed. But I found some users could not show the main window and the main window be lock in PenThreadWorker constructor. I use dnspy to suspend the application and find the code run in PenThreadWorker constructor and the UnsafeNativeMethods.CreateResetEvent will lock the thread.
     PenThreadWorker..ctor()  
     PenThread..ctor()  
     PenThreadPool.GetPenThreadForPenContextHelper(PenContext penContext)  
     PenThreadPool.GetPenThreadForPenContext(PenContext penContext)  
     WispTabletDeviceCollection.UpdateTabletsImpl()  
     WispTabletDeviceCollection.UpdateTablets()  
     WispTabletDeviceCollection..ctor()  
     WispLogic.get_WispTabletDevices()  
     WispLogic.RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource)  
     HwndStylusInputProvider..ctor(HwndSource source)  
     HwndSource.Initialize(HwndSourceParameters parameters)  
     HwndSource..ctor(HwndSourceParameters parameters)  
     PresentationFramework.dll!System.Windows.Window.CreateSourceWindow(bool duringShow)  
     PresentationFramework.dll!System.Windows.Window.CreateSourceWindowDuringShow()  
     PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox)  
    

    Expected behavior: The UnsafeNativeMethods.CreateResetEvent do not lock the thread

Minimal repro:

Create a empty WPF application and then change the app.xaml.cs code

    public partial class App : Application
    {
        /// <inheritdoc />
        protected override void OnStartup(StartupEventArgs e)
        {
            var thread = new Thread(() =>
            {
                var mainWindow = new MainWindow();
                mainWindow.Show();
                Dispatcher.Run();
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            base.OnStartup(e);
        }
    }

Run the code and maybe you can find one of the main window can not show and it stop in UnsafeNativeMethods.CreateResetEvent and I wait for a hour but it can not run.

高效率工具

本文分享一些提高效率工具

win10 uwp 商业游戏

本文告诉大家去做一个商业游戏,游戏很简单,几乎没有什么技术。

如何在 UWP 使用 wpf 的 Trigger

本文需要告诉大家,如何使用 Behaviors 做出 WPF 的 Trigger ,需要知道 UWP 不支持 WPF 的 Trigger 。

在 Gitlab 开启 MatterMost 机器人

在 Gitlab 上有 MatterMost 插件可以用于订阅 Gitlab 上的事件,本文告诉大家如何使用插件只需要三步就可以关联 Gitlab 和 MatterMost 使用机器人订阅事件

WPF 绑定密码

我们发现我们无法绑定密码框的密码,PasswordBox 的 Password 不能绑定。 我们想做 MVVM ,我们需要绑定密码,不能使用前台 xaml.cs 监听 密码改变得到密码的值,传到 ViewModel 。 本文提供一个简单方法来绑定 WPF 的 PasswordBox 的 Password 。这种方法不仅在 WPF 可以使用,在 UWP 也可以使用。关于 UWP 绑定密码,可以在我博客 win10 uwp 绑定密码 查看。

WPF 解决 ListView 的滚动条不显示

本文告诉大家如何解决一个诡异的问题,如果有一个 ListView 同时里面的元素的高度很长,但是滚动条就是不显示,怎么让这个滚动条显示

wpf 绑定 TextLength

我看到朋友的代码出现绑定了 一个 TextBlock 的 Text 的 length ,那时候我觉得 length 不是依赖属性,绑定了是无法通知的。最后我做了实验才发现,原因有 Text 可以通知。

WPF 如何调试 binding

如果是写在 xaml 的绑定,很难看到是那里出错。本文告诉大家如何在 vs 调试 binding 是否绑定上?

WPF 依赖属性绑定不上调试方法

在写 WPF 程序的时候会遇到依赖属性绑定了,但是值没有更新或者没有绑定上的问题,本文告诉大家可以如何调试

WPF 使用RPC调用其他进程

如果在 WPF 需要用多进程通信,一个推荐的方法是 WCF ,因为 WCF 是 RPC 计算。先来讲下 RPC (Remote Procedure Call) 远程过程调用,他是通过特定协议,包括 tcp 、http 等对其他进程进行调用的技术。详细请看百度

WPF 从零开始开发 dotnet Remoting 程序

本文告诉大家如何不使用框架,从零开始开发一个 dotnet remoting 程序

wpf GifBitmapDecoder 解析 gif 格式

在网上有很多图片都是gif,那么如何在 wpf 解析 gif? 本文告诉大家如何使用 GifBitmapDecoder 把gif分开为一张一张,获得他的信息。

win10 uwp win2d 入门 看这一篇就够了

本文主要翻译微软官方的文档和添加一些在开发过程比较多小伙伴问的问题,可能带有一定的主观性和局限性,说的东西可能不对或者不符合每个人的预期。如果觉得我有讲的不对的,就多多包含,或者直接关掉这篇文章,但是请勿生气或者发怒吐槽,欢迎在我博客评论

win10 uwp 如何使用DataTemplate

这是数据模板,一般用在数组的绑定,显示数组中的元素。 假如我们有一个列表,列表里是书,包括书名、作者、还有出版,那么我们只有源信息,如何把它显示到我们的ListView,就需要DataTemplate。 使用很简单,我们可以定义在资源,也可以定义在ItemTemplate。 数据模板有绑定的问题。 我们使用Binding和WPF其实没有多少不同,在Mode只有OneWay,OneTime,TwoWay。我们使用的x:bind在DataTemplate才和原来有一些不同。 我们使用x:bind需要我们对我们数据的类型,这个在前没有,我开始不知,弄了好久,最后才知道,还有一个,UWP默认是OneTime,也就是绑定只有一次。

win10 uwp 打包第三方字体到应用

有时候我们会把一些特殊字体打包到软件,因为如果找不到我们的字体会变为默认,现在很多字体图标我们用得好,有时候我们的应用会用很漂亮的字体,需要我们自己打包,因为用户一般是没有字体。 本文告诉大家如何在 UWP 内置字体,把字体打包到应用

win10 uwp 右击浮出窗在点击位置

如果需要让 Flyout 显示在指定的位置,那么请看本文。 本文主要让 MenuFlyout 出现在我们右击位置。

win10 uwp 读取保存WriteableBitmap 、BitmapImage

我们在UWP,经常使用的图片,数据结构就是 BitmapImage 和 WriteableBitmap。关于 BitmapImage 和 WriteableBitmap 区别,我就不在这里说。主要说的是 BitmapImage 和 WriteableBitmap 、二进制 byte 的互转。

win10 uwp 资源字典

本文告诉大家如何定义、使用资源

win10 UWP 序列化

将对象的状态信息转换为可以存储或传输的形式的过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区。以后,可以通过从存储区中读取或反序列化对象的状态,重新创建该对象。

win10 uwp 如何打包Nuget给其他人

本文告诉大家,如果自己有做一些好用的库,如何使用 Nuget 打包之后上传,分享给大家。

win10 UWP 动画

本文告诉大家如何写同一个简单的动画。

win10 uwp 依赖属性

本文告诉大家如何使用依赖属性,包括在 UWP 和 WPF 如何使用。 本文不会告诉大家依赖属性的好处,只是简单告诉大家如何使用。

win10 uwp x:Bind 无法获得资源

本文告诉大家,如果在 使用 x:Bind 转换器写在资源,而运行出现找不到资源的错误,如果解决。 在运行的时候,出现System.Runtime.InteropServices.COMException Cannot find a resource with the given key