网站怎么做的有创意,泉州seo排名,保定软件开发网站制作,做网站ps分辨率给多少钱今天看到群里一个小页面挺有意思的#xff0c;就是这个#xff1a;https://ac.yunyoujun.cn/于是想着用wpf也模仿一下嘿嘿#xff0c;为了方便#xff0c;也顾不上什么代码结构了。。。看看效果吧#xff1a;代码不多#xff0c;只有一个窗口#xff0c;下面就直接看看代… 今天看到群里一个小页面挺有意思的就是这个https://ac.yunyoujun.cn/于是想着用wpf也模仿一下嘿嘿为了方便也顾不上什么代码结构了。。。看看效果吧代码不多只有一个窗口下面就直接看看代码窗体xaml:Window x:ClassAirCond.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:AirCondResizeModeNoResizeWindowStyleNoneTopmostTrueAllowsTransparencyTrueBackgroundTransparentWidth300SizeToContentHeightmc:IgnorabledTitleMainWindowStackPanelBorder Height120 MouseDownBorder_MouseDown VerticalAlignmentTop Background#F8F8F8 Margin10 CornerRadius15 15 30 30Border.EffectDropShadowEffect ShadowDepth0 BlurRadius10 Color#66ffffff//Border.EffectGridlocal:IconFontButton x:NameshutDownButton ClickShutDownClick Geometry{StaticResource ShutDownIcon} HorizontalAlignmentRight VerticalAlignmentTop IconWidth16 IconHeight16 Margin3 ForegroundRed/Image Width40 Height70 Source/info.png Margin10 HorizontalAlignmentLeft VerticalAlignmentTop/Image x:Namesnow Width26 Height32 Source/snow.png HorizontalAlignmentRight VerticalAlignmentTop Margin0 15 66 0/TextBlock x:NametempText Text{Binding Temp,StringFormat{}{0}°C} HorizontalAlignmentRight Margin0 40 30 0 FontSize33 FontWeightBold FontFamily{StaticResource Digital} ForegroundRed/Border Height1 BackgroundGray Margin0 56 0 0 /TextBlock TextPowered by WPF Foreground{StaticResource LinearBrush} FontFamily微软雅黑 FontSize10 VerticalAlignmentBottom HorizontalAlignmentCenter Margin0 0 0 35/TextBlock Text新能源空调靠爱发电 Foreground{StaticResource LinearBrush} Opacity0.5 Padding6 FontSize14 TextAlignmentCenter FontFamily微软雅黑 HorizontalAlignmentStretch VerticalAlignmentBottom/TextBlock/Grid/BorderGrid x:NamewindGrid Height60 Width200 VisibilityVisibleGrid.ColumnDefinitionsColumnDefinition/ColumnDefinition/ColumnDefinition//Grid.ColumnDefinitionsBorder Grid.Column0 Width6 Height50 RenderTransformOrigin0.5,0.5 Background#0BE8EBBorder.RenderTransformRotateTransform Angle15//Border.RenderTransform/BorderBorder Grid.Column1 Width6 Height50 Background#0BE8EB/Border Grid.Column2 Width6 Height50 RenderTransformOrigin0.5,0.5 Background#0BE8EBBorder.RenderTransformRotateTransform Angle-15//Border.RenderTransform/Border/Grid/StackPanel
/Window窗体后台代码using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;namespace AirCond
{public partial class MainWindow : Window,INotifyPropertyChanged{public MainWindow(){InitializeComponent();DataContext this;MouseWheel MainWindow_MouseWheel;}private void MainWindow_MouseWheel(object sender, MouseWheelEventArgs e){Temp (e.Delta 0 ? 1 : -1);}private int _temp16;public int Temp{get { return _temp; }set { _temp value;_temp Math.Min(31, _temp);_temp Math.Max(16, _temp);OnPropertyChanged(nameof(Temp)); }}private bool _isOpentrue;public bool IsOpen{get { return _isOpen; }set { _isOpen value;OnPropertyChanged(nameof(IsOpen));SetUI();}}private void SetUI(){shutDownButton.Foreground _isOpen ? Brushes.Red : Brushes.Gray;if (_isOpen){StartAnimationIn(snow);StartAnimationIn(windGrid);StartAnimationIn(tempText);}else{StartAnimationOut(snow);StartAnimationOut(windGrid);StartAnimationOut(tempText);}}private async void StartAnimationIn(FrameworkElement element, float seconds0.5f){var sb new Storyboard();var fadeIn new DoubleAnimation{Duration new Duration(TimeSpan.FromSeconds(seconds)),To 1,};Storyboard.SetTargetProperty(fadeIn, new PropertyPath(Opacity));sb.Children.Add(fadeIn);sb.Begin(element);await Task.Delay((int)(seconds * 1000));}private async void StartAnimationOut(FrameworkElement element, float seconds 0.5f){var sb new Storyboard();var fadeIn new DoubleAnimation{Duration new Duration(TimeSpan.FromSeconds(seconds)),To 0,};Storyboard.SetTargetProperty(fadeIn, new PropertyPath(Opacity));sb.Children.Add(fadeIn);sb.Begin(element);await Task.Delay((int)(seconds * 1000));}public event PropertyChangedEventHandler PropertyChanged;public void OnPropertyChanged(string name){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));}private void Border_MouseDown(object sender, MouseButtonEventArgs e){if(e.LeftButtonMouseButtonState.Pressed)this.DragMove();}private void ShutDownClick(object sender, RoutedEventArgs e){IsOpen !IsOpen;}}
}
在App.xaml里面定义资源Application x:ClassAirCond.Appxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:localclr-namespace:AirCondStartupUriMainWindow.xamlApplication.ResourcesFontFamily x:KeyDigitalpack://application;,,,/Fonts/#Digital-7 Mono/FontFamilyPathGeometry x:KeyShutDownIcon FiguresM209.664 813.696a426.666667 426.666667 0 0 1 0-603.392 42.666667 42.666667 0 0 1 60.330667 60.330667 341.333333 341.333333 0 1 0 482.474666 0 42.666667 42.666667 0 0 1 60.330667-60.330667A426.666667 426.666667 0 0 1 209.664 813.696zM511.36 85.333333a42.666667 42.666667 0 0 1 42.666667 42.666667v384a42.666667 42.666667 0 0 1-85.333334 0V128a42.666667 42.666667 0 0 1 42.666667-42.666667z/LinearGradientBrush x:KeyLinearBrushGradientStop Offset0 ColorRed/GradientStop Offset0.5 ColorBlue/GradientStop Offset1 ColorGreen//LinearGradientBrushStyle TargetTypelocal:IconFontButtonSetter PropertyCornerRadius Value0/Setter PropertyPadding Value5/Setter PropertyBackground ValueTransparent/Setter PropertyForeground ValueGray/Setter PropertyBorderBrush ValueTransparent/Setter PropertyFocusVisualStyle Value{x:Null}/Setter PropertyTemplateSetter.ValueControlTemplate TargetTypelocal:IconFontButtonBorder CornerRadius{TemplateBinding CornerRadius} Background{TemplateBinding Background} BorderThickness0Path x:Namepath Data{TemplateBinding Geometry} Fill{TemplateBinding Foreground}Width{TemplateBinding IconWidth}Height{TemplateBinding IconHeight}SnapsToDevicePixelsTrueStretchUniformRenderTransformOrigin0.5,0.5Margin{TemplateBinding Padding}Path.RenderTransformTransformGroupScaleTransform ScaleX1 ScaleY1 //TransformGroup/Path.RenderTransform/Path/BorderControlTemplate.TriggersEventTrigger RoutedEventUIElement.MouseEnterBeginStoryboard StoryboardDoubleAnimation Storyboard.TargetNamepath Storyboard.TargetProperty(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX) To1.2 Duration0:0:0.1 AutoReverseFalse /DoubleAnimation Storyboard.TargetNamepath Storyboard.TargetProperty(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY) To1.2 Duration0:0:0.1 AutoReverseFalse //Storyboard/BeginStoryboard/EventTriggerEventTrigger RoutedEventUIElement.MouseLeaveBeginStoryboardStoryboardDoubleAnimation Storyboard.TargetNamepath Storyboard.TargetProperty(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX) To1 Duration0:0:0.1 AutoReverseFalse /DoubleAnimation Storyboard.TargetNamepath Storyboard.TargetProperty(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY) To1 Duration0:0:0.1 AutoReverseFalse //Storyboard/BeginStoryboard/EventTrigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter
/Style/Application.Resources
/Application创建一个IconFontButton类using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;namespace AirCond
{public class IconFontButton : Button{public Geometry Geometry{get { return (Geometry)GetValue(GeometryProperty); }set { SetValue(GeometryProperty, value); }}public static readonly DependencyProperty GeometryProperty DependencyProperty.Register(Geometry, typeof(Geometry), typeof(IconFontButton), new PropertyMetadata(default(Geometry)));public CornerRadius CornerRadius{get { return (CornerRadius)GetValue(CornerRadiusProperty); }set { SetValue(CornerRadiusProperty, value); }}public static readonly DependencyProperty CornerRadiusProperty DependencyProperty.Register(CornerRadius, typeof(CornerRadius), typeof(IconFontButton), new PropertyMetadata(default(CornerRadius)));public double IconWidth{get { return (double)GetValue(IconWidthProperty); }set { SetValue(IconWidthProperty, value); }}public static readonly DependencyProperty IconWidthProperty DependencyProperty.Register(IconWidth, typeof(double), typeof(IconFontButton), new PropertyMetadata(32.0));public double IconHeight{get { return (double)GetValue(IconHeightProperty); }set { SetValue(IconHeightProperty, value); }}public static readonly DependencyProperty IconHeightProperty DependencyProperty.Register(IconHeight, typeof(double), typeof(IconFontButton), new PropertyMetadata(32.0));}
}
图片和字体来源于网络仅用于学习用途如有侵权请联系我删除。如需图片和字体资源请下载项目代码百度云链接给白嫖怪的惊喜链接https://pan.baidu.com/s/1R1lxv-rcQI3rytn3epJP6Q提取码s5hl效果图:如果喜欢点个赞呗~