国外财经网站是怎么做的,营销型定制网站,h5建站是什么,腾讯企业邮箱账号WPF 开发的 Windows 软件快捷助手Windows 软件快捷助手作者#xff1a;WPFDevelopersOrg - 驚鏵原文链接#xff1a;https://github.com/WPFDevelopersOrg/SoftwareHelper框架使用.NET40#xff1b;Visual Studio 2019;项目使用 MIT 开源许可协议#xff1b;项目使用 MVV… WPF 开发的 Windows 软件快捷助手Windows 软件快捷助手作者WPFDevelopersOrg - 驚鏵原文链接https://github.com/WPFDevelopersOrg/SoftwareHelper框架使用.NET40Visual Studio 2019;项目使用 MIT 开源许可协议项目使用 MVVM 模式来实现详细学习和理解 WPF新增功能通过托盘设置是否开机启动。增加外部文件可拖放入到应用。项目中技术使用到WindowsAPI 、Style、CustomControl、Json 序列化和反序列化、换肤 Dark|Light、动画、Hook 按键与鼠标、颜色拾取、截图工具、DPI缩放、开机启动、NLog、转换器、禁止程序多开并唤醒之前程序等欢迎下载项目进行魔改更多效果可以通过GitHub[1]|码云[2]下载源码;需注意程序不能以管理员身份运行因为管理员身份运行Drop操作无效。1要允许控件Drop操作首先必须设置控件属性AllowDropTrue这样控件才能产生DragOver/DragEnter/Drop等相关事件代码如下Canvas BackgroundTransparent x:NameDragCanvasAllowDropTrue DragOverDragCanvas_DragOverDropDragCanvas_DropVisibilityCollapsedStackPanel OrientationVertical NameDragStackPanelRenderTransformOrigin.5,.5Opacity.5StackPanel.RenderTransformScaleTransform x:NameDragScaleTransform ScaleX1 ScaleY1//StackPanel.RenderTransformImage x:NameDragImage StretchUniform/TextBlock NameDragTextBlockMaxWidth70 TextWrappingWrapVerticalAlignmentCenterBlock.TextAlignmentCenter HorizontalAlignmentCenterTextTrimmingCharacterEllipsisMaxHeight40Foreground{DynamicResource NormalWhiteBrush}//StackPanel/Canvas2 后台实现拖拽代码如下private void DragCanvas_DragOver(object sender, DragEventArgs e){try{if (e.Data.GetDataPresent(DataFormats.FileDrop)){var msg ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();filePath msg;DragTextBlock.Text System.IO.Path.GetFileName(filePath);var icon (BitmapSource)Common.GetIcon(filePath);fileIcon icon;DragImage.Source fileIcon;var point e.GetPosition(this);var x point.X - DragStackPanel.ActualWidth / 2;var y point.Y - DragStackPanel.ActualHeight / 2;Canvas.SetLeft(DragStackPanel, x);Canvas.SetTop(DragStackPanel, y);}}catch (Exception ex){Log.Error(DragCanvas_DragOver: ex.Message);}}private void embedDeasktopView_DragEnter(object sender, DragEventArgs e){AppSwitchListEmbedded.IsHitTestVisible false;AppSwitchList.IsHitTestVisible false;var doubleXAnimation new DoubleAnimation{From 0,To 1,Duration new Duration(TimeSpan.FromSeconds(0)),};DragScaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty,doubleXAnimation);var doubleYAnimation new DoubleAnimation{From 0,To 1,Duration new Duration(TimeSpan.FromSeconds(0)),};DragScaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, doubleXAnimation);DragCanvas.Visibility Visibility.Visible;}private void embedDeasktopView_DragLeave(object sender, DragEventArgs e){DragInitial();}void DisposeDrag(){var storyboard new Storyboard();var doubleXAnimation new DoubleAnimation{From 1,To 0,Duration new Duration(TimeSpan.FromSeconds(0.5)),EasingFunction new BackEase { EasingMode EasingMode.EaseIn },};Storyboard.SetTargetName(doubleXAnimation, DragStackPanel);Storyboard.SetTargetProperty(doubleXAnimation, new PropertyPath((StackPanel.RenderTransform).(ScaleTransform.ScaleX)));var doubleYAnimation new DoubleAnimation{From 1,To 0,Duration new Duration(TimeSpan.FromSeconds(0.5)),EasingFunction new BackEase { EasingMode EasingMode.EaseIn },};Storyboard.SetTargetName(doubleYAnimation, DragStackPanel);Storyboard.SetTargetProperty(doubleYAnimation, new PropertyPath((StackPanel.RenderTransform).(ScaleTransform.ScaleY)));storyboard.Children.Add(doubleXAnimation);storyboard.Children.Add(doubleYAnimation);storyboard.Completed delegate {DragInitial();var model new ApplicationModel();model.ExePath filePath;model.Name DragTextBlock.Text;var iconPath System.IO.Path.Combine(Common.TemporaryIconFile, model.Name);iconPath iconPath .png;model.IconPath iconPath;model.IsDrag true;var firstModel mainVM.ApplicationList.FirstOrDefault(x x.Name model.Name x.ExePath model.ExePath);if (firstModel ! null) return;string first model.Name.Substring(0, 1);if (!Common.IsChinese(first)){if (char.IsUpper(first.ToCharArray()[0]))model.Group first;model.Group model.Name.Substring(0, 1).ToUpper();}else{model.Group Common.GetCharSpellCode(first);}mainVM.ApplicationList.Insert(0, model);if (File.Exists(iconPath))return;Common.SaveImage(fileIcon, iconPath);};storyboard.Begin(DragStackPanel);}void DragInitial(){try{DragCanvas.Visibility Visibility.Collapsed;AppSwitchListEmbedded.IsHitTestVisible true;AppSwitchList.IsHitTestVisible true;}catch (Exception ex){Log.Error(DragInitial: ex.Message);}}private void DragCanvas_Drop(object sender, DragEventArgs e){if (string.IsNullOrWhiteSpace(filePath)){DragInitial();return; }DisposeDrag();}体验地址1[3]体验地址2[4]参考资料[1]GitHub: https://github.com/WPFDevelopersOrg/SoftwareHelper[2]码云: https://gitee.com/WPFDevelopersOrg/SoftwareHelper[3]体验地址1: https://github.com/WPFDevelopersOrg/SoftwareHelper/releases/download/1.0.0.1/SoftwareHelper_Setup1.0.0.1.exe[4]体验地址2: https://gitee.com/WPFDevelopersOrg/SoftwareHelper/releases/download/1.0.0.1/SoftwareHelper_Setup1.0.0.1.exe