WPF窗口长时间无人操作鼠标自动隐藏

一、封装好的监视鼠标移动的类文件:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Runtime.InteropServices;namespaceEBS.Common{publicclassMouseMonitorHelper{privatestaticPointmousePosition;//鼠标的位置publicstaticintCheckCount;//检测鼠标位置的次数//判断鼠标是否移动publicstaticboolHaveUsedTo(){Pointpoint=GetMousePoint();if(point==mousePosition)returnfalse;mousePosition=point;returntrue;}[StructLayout(LayoutKind.Sequential)]privatestructMPoint{publicintX;publicintY;publicMPoi...

WPF中找不到Image或者Image不是Drawing系列

WPF中默认没有引用WinForm里面的一些东西,都是用它自带的那一套,但又不能完全脱离,所以有的时候比较蛋疼 ...

逆天通用水印支持Winform,WPF,Web,WP,Win10。支持位置选择(9个位置 ==》[X])

常用技能:http://www.cnblogs.com/dunitian/p/4822808.html#skill逆天博客:http://dnt.dkil.net逆天通用水印扩展篇~新增剪贴板系列的功能和手动配置,卸除原基础不常用的功能:http://www.cnblogs.com/dunitian/p/5377097.html好几天没上QQ了,今天上了个QQ,,额....额...貌似消息还挺多,没及时回复的还请见谅~~刚好昨天无聊把水印这快封装出来了,支持图片水印,文字水印,索引图水印和非索引图水印,支持位置选择(9个位置==》[X])。好吧不高兴屁话了,软件是WPF的(只满足我的需求,如果有需要可以出第个二版本),水印核心代码封装了个Helper类(通用:支持Winform,WPF,Web,WP,Win10)软件共享一下==>http://pan.baidu.com/s/1qWDwv4C源码看下面水印类///<summary>///水印类(重要参数:原图类型,水印类型,水印位置,图片水印路径,文字水印内容)///</summary>publicclas...

WP、Win10开发或者WPF开发时绘制自定义窗体~例如:一个手机

WPandWin10效果:(数字是参考值,和UI无关)<Pagex:Class="_05.AllControls._BorderUsePage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:_05.AllControls"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"Background="{ThemeResourceApplicationPageBackgroundThemeBrush}"><!--快乐玩耍:DIV一个手机--><Grid><!--手机整体--><...

WPF之MVVM实践中的Command与CommandParameter

先记录一下,方便以后复习。https://www.cnblogs.com/babietongtianta/p/3474101.html...

WPF之BackgroundWorker

BackgroundWorker类允许您在单独的线程上执行某个可能导致用户界面(UI)停止响应的耗时操作,下面来介绍一下这个线程类BackgroundWorker,大家可以结合这位大佬的这篇文章,说的比较仔细https://www.cnblogs.com/zhaoshujie/p/9634136.html1.属性//bool类型,指示应用程序是否已请求取消后台操作。此属性通常放在用户执行的异步操作内部,用来判断用户是否取消执行异步操作。当执行BackgroundWorker.CancelAsync()方法时,该属性值将变为True。publicboolCancellationPending{get;}//bool类型,指示BackgroundWorker是否正在执行一个异步操作。此属性通常放在BackgroundWorker.RunWorkerAsync()方法之前,避免多次调用RunWorkerAsync()方法引发异常。当执行BackgroundWorker.RunWorkerAsync()方法是,该属性值将变为True。publicboolIsBusy{get;}//bool类型...
代码星球 代码星球·2021-02-23

WPF之lognet4的基本使用

log4net是.Net下一个非常优秀的开源日志记录组件。log4net记录日志的功能非常强大。它可以将日志分不同的等级,以不同的格式,输出到不同的媒介。本文介绍lognet4的基本使用。第一步:新建一个项目LoginUI,然后在该项目下新建一个日志管理类LogManager,再添加对lognet4.dll的引用namespaceLoginUI{publicclassLogManager{privatestaticLogManager_instance;privatestaticlog4net.ILog_logger;protectedLogManager(){InitialiseLogger();}publicstaticLogManagerInstance{get{if(_instance==null)_instance=newLogManager();return_instance;}}publiclog4net.ILogLogger{get{return_logger;}}voidInitialiseLogger(){//通过系统配置文件配置logger,GUIClientLo...
代码星球 代码星球·2021-02-23

C#中Brush、Color、String相互转换WPF/Silverlight

//部分方法只适用于WPF,在SL中不能用usingSystem.Windows.Media;Colorcolor=(Color)ColorConverter.ConvertFromString(string);BrushConverterbrushConverter=newBrushConverter();Brushbrush=(Brush)brushConverter.ConvertFromString(string);Brushbrush=newSolidColorBrush(color));(1)先将Brush转成string,再转成Color。      Colorcolor=(Color)ColorConverter.ConvertFromString(brush.ToString());(2)将Brush转成SolidColorBrush,再取Color。      Colorcolor=((SolidColorBrush)CadColor.Backgr...

Silverlight/WPF绘制统计图Visifire.dll文件

官网:http://www.visifire.com/一直没找到好的中文文档,希望有的这个的可以发个我!效果图:前台代码:<UserControlx:Class="Text_Visifire.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"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"xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"mc:Ignorable="d"xmlns:navigation="clr-namespace:System.Windows.Controls;asse...

WPF笔记(2.4 Grid)

第一章已经简单介绍过这个容器,这一节详细介绍。Grid一般是用表格(Grid.Row 和Grid.Column )的,比StackPanel更细致一些,但是,这么玩很麻烦,先横着竖着定义一大堆,然后把元素指定其表格位置,即插入数据,和我们平常习惯的HTML表格不太一样,甚至更麻烦了。原因如下:Html空单元格要放占位符,这样会放很多;Grid玩法则是用什么元素就指定单元格位置,不用的单元格默认是空,不用指定。另外,Grid单元格中的多个控件可以按照Z轴堆叠,这个顺序是由控件在xaml上的出现顺序决定的。Grid列宽的定义:<Grid.ColumnDefinitions>    <ColumnDefinition Width="50" />    <ColumnDefinition Width="Auto" />    <ColumnDefinition Wi...
代码星球 代码星球·2021-02-18

[WPF实用技巧]如何使WPF的TreeView节点之间有连线

IntroductionWPFdefault TreeView isverygood,butmanypeoplestillwantittohavelinesjoineachofitschildelements,likeWindowsForms TreeView,includingme.Ihavesearchedontheinternetandhavesomeexamples,buttheywerenotdesignedwellenough.Now,Imyselfdesigneda TreeView withstyleasWinForms.Hopethiswillhelpmanypeople!AllyouneedisanXAMLfileandacodebehind.First,youneeddrawToggleButton:FromTrianglebuttontoPlus-Minusbutton:drawarectanglewithdarkborder,thendrawtwolines,oneverticallineandonehoriz...

Walkthrough: My first WPF desktop application

ThisarticleshowsyouhowtodevelopaWindowsPresentationFoundation(WPF)desktopapplicationthatincludestheelementsthatarecommontomostWPFapplications:ExtensibleApplicationMarkupLanguage(XAML)markup,code-behind,applicationdefinitions,controls,layout,databinding,andstyles.Todeveloptheapplication,you'lluseVisualStudio.Thiswalkthroughincludesthefollowingsteps:UseXAMLtodesigntheappearanceoftheapplication'suserinterface(UI).Writecodetobuildtheapplication'sbehavior.Createanapplicationdefinitiontomanagetheappli...

WPF global exception handler

https://stackoverflow.com/questions/1472498/wpf-global-exception-handler/1472562#1472562Youcantrapunhandledexceptionsatdifferentlevels:AppDomain.CurrentDomain.UnhandledException FromallthreadsintheAppDomain.Dispatcher.UnhandledException FromasinglespecificUIdispatcherthread.Application.Current.DispatcherUnhandledException Fromthe main UIdispatcherthreadinyourWPFapplication.TaskScheduler.UnobservedTaskException fromwithineachAppDomainthatusesataskschedulerforasynchro...
代码星球 代码星球·2021-02-08

WPF,强制捕获鼠标事件,鼠标移出控件外依然可以执行强制捕获的鼠标事件

WPF中,只有鼠标位置在某个控件上的时候才会触发该控件的鼠标事件。例如,有两个控件都注册了MouseDown和MouseUp事件,在控件1上按下鼠标,不要放开,移动到控件2上再放开。在这个过程中,控件1只会触发MouseDown事件,而控件2则只会触发MouseUp事件,鼠标不在控件上他们就收不到对应的鼠标事件。同样的如果某个控件注册了MouseMove事件,当鼠标移动到控件外之后,控件将不会接收到MouseMove事件。但是在很多情况下我们需要在鼠标移动到控件外之后还能接收鼠标事件。例如按住鼠标拖动,当鼠标到了控件外,拖动操作依然可以继续。这些情况需要控件强制捕获鼠标,这就要用到UIElment的CaptureMouse函数和ReleaseMouseCapture函数。CaptureMouse函数的作用是尝试将鼠标强制捕获到控件,ReleaseMouseCapture函数的作用是当控件具有鼠标捕获的话,则释放该捕获。下面举个例子,例如我们需要在一张图片上通过鼠标拖动画一个矩形框,操作步骤分为:1.点击鼠标左键,确定矩形的一个顶点P;2.按住鼠标左键并拖动鼠标,将鼠标位置作为矩形中顶...

WPF 中如何创建忽略 DPI 属性的图片

WPF 框架设计为与DPI无关,但你依然可能遇到DPI问题。尤其是 Image 控件显示的图片会根据图片EXIF中的DPI信息和屏幕DPI自动缩放图片。对于UI用图来说这是好事,但对于软件用户随便插入的图片来说就不是了——用户传入的图片可能是各种各样不统一的DPI。因此这种DPI我们应该忽略。 直接设置 Image 控件的大小是一个不错的方案,这在允许设置 Image 控件大小的场合下是可以使用的。如果你能设置,那么直接设置,这是最好的方法了。除此之外,我们还可能可以尝试这些方法:创建 BitmapImage 对象,根据当前屏幕的DPI值计算 DecodePixelWidth 和 DecodePixelHeight ;创建 DrawingImage 对象,直接按照WPF的坐标单位绘制图片原始像素大小的图片;创建 Bitmap / WriteableBitmap 对象,重新创建一张96DPI...
首页上一页12345...下一页尾页