惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
P
Privacy International News Feed
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
F
Fortinet All Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 最新话题
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
Recent Announcements
Recent Announcements
Recent Commits to openclaw:main
Recent Commits to openclaw:main
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
J
Java Code Geeks
M
MIT News - Artificial intelligence
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
G
Google Developers Blog
W
WeLiveSecurity
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
T
Tailwind CSS Blog
V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Secure Thoughts
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
Blog — PlanetScale
Blog — PlanetScale
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed

博客园 - HotSky

Chrome启用CDP(chrome-devtools-protocol)进行远程操控 WPF 让ScrollViewer支持按住鼠标中键拖拽滚动内容 WPF 让ScrollViewer支持鼠标中键滚动缩放内容 Nodejs使用 nodejs中写sql需要用in时的写法 C#城市最短路径 C#Animation Sqlite PDF附录A: 内容流操作码 生命模拟 C# Sql帮助类,可扩展 WPF WriteableBitmap通过GDI+绘制帮助类 Alpha混合 Bmp读写二值图 WPF支持任意快捷键+鼠标组合的绑定类 WPF阻止窗体被系统缩放,使用显示器DPI WPF DataGrid自动增长序号列 C#访问或修改私有类、函数、变量、属性 WPF一个简单的属性编辑控件
WPF FPS类
HotSky · 2024-11-13 · via 博客园 - HotSky
public class FPSBase
{
    public static void Run()
    {
        CompositionTarget.Rendering += CompositionTarget_Rendering;
    }

    public static TimeSpan RunTime { get; private set; }
    public static int FPS { get; private set; }
    static int fps = 0;
    public static TimeSpan PreSTime { get; private set; }
    public static TimeSpan PreLogicTime { get; private set; }

    public static double Logicalnterval { get; set; } = 16d;

    private static void CompositionTarget_Rendering(object sender, EventArgs e)
    {
        RunTime = (e as RenderingEventArgs).RenderingTime;
        var span = (RunTime - PreSTime).TotalSeconds;
        if (span >= 1d)
        {
            PreSTime = RunTime;
            FPS = fps;
            fps = 0;
        }
        else
            fps++;
        if ((RunTime - PreLogicTime).TotalMilliseconds > Logicalnterval)
        {
            PreLogicTime = RunTime;
            OnLogicFrame();
        }
        OnRenderFrame();
    }

    static EventHandlerList Events = new EventHandlerList();
    static readonly object LogicFrameEventObj = new object();
    static readonly object RenderFrameEventObj = new object();
    public static event EventHandler LogicFrameEvent { add => Events.AddHandler(LogicFrameEventObj, value); remove => Events.RemoveHandler(LogicFrameEventObj, value); }
    public static event EventHandler RenderFrameEvent { add => Events.AddHandler(RenderFrameEventObj, value); remove => Events.RemoveHandler(RenderFrameEventObj, value); }
    private static void OnLogicFrame()
    {
        (Events[LogicFrameEventObj] as EventHandler)?.Invoke(null, EventArgs.Empty);
    }

    static void OnRenderFrame()
    {
        (Events[RenderFrameEventObj] as EventHandler)?.Invoke(null, EventArgs.Empty);
    }
}