【.Net码农】WPF界面—仿360安全卫士9.0界面
来源:互联网 发布:淘宝一键好复制怎么用 编辑:程序博客网 时间:2024/04/30 06:19
http://blog.csdn.net/ljf5566/article/details/8758922
主要思路如下:
该界面主要有三大部分
第一部分:标题栏部分就是最上面那一行
第二部分:内容区域(也就是页标签部分)
第三部分:换肤部分(点击换肤小按钮弹出的内容部分)
根据分析我们可以使用一个有两行的网格(Grid)进行布局,第一行“标题栏”部分;第二行“页标签部分”,对于“换肤部分”是直接显示在当前界面之上的内容,使用"Popup"标签实现。
代码很长,我只粘贴部分代码,随后将上传至资源区
1、定义无边框窗体样式和Button样式
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <!--无边框的窗体样式-->
- <Style x:Key="NoResize_window" TargetType="{x:Type Window}">
- <Setter Property="AllowsTransparency" Value="true"/>
- <Setter Property="Background" Value="Transparent"/>
- <!-- <Setter Property="ResizeMode" Value="CanResizeWithGrip"/>-->
- <Setter Property="WindowStyle" Value="None"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Window}">
- <Grid Margin="5">
- <Rectangle Fill="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" >
- <Rectangle.Effect>
- <DropShadowEffect BlurRadius="5" ShadowDepth="0"/>
- </Rectangle.Effect>
- </Rectangle>
- <Border Background="{TemplateBinding Background}"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}"
- Padding="{TemplateBinding Margin}"
- SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
- <ContentPresenter />
- </Border>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!--Button样式-->
- <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="MouseOver"/>
- <VisualState x:Name="Pressed"/>
- <VisualState x:Name="Disabled"/>
- </VisualStateGroup>
- <VisualStateGroup x:Name="FocusStates">
- <VisualState x:Name="Focused"/>
- </VisualStateGroup>
- <VisualStateGroup x:Name="ValidationStates">
- <VisualState x:Name="InvalidFocused"/>
- <VisualState x:Name="InvalidUnfocused"/>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="5">
- <Border.Effect>
- <DropShadowEffect ShadowDepth="0" Opacity="0.85"/>
- </Border.Effect>
- </Border>
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}"/>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsFocused" Value="True"/>
- <Trigger Property="IsDefaulted" Value="True"/>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Effect" TargetName="border">
- <Setter.Value>
- <DropShadowEffect Color="#FF00F3FF" Opacity="0.85" ShadowDepth="0"/>
- </Setter.Value>
- </Setter>
- </Trigger>
- <Trigger Property="IsPressed" Value="True"/>
- <Trigger Property="IsEnabled" Value="False"/>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- Resource dictionary entries should be defined here. -->
- </ResourceDictionary>
2、逻辑处理代码
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Xml;
- namespace _360UI9
- {
- /// <summary>
- /// MainWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- this.Loaded += MainWindow_Loaded;
- }
- void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- //窗体加载的时候获取保存的皮肤
- XmlDocument doc = new XmlDocument();
- string xmlpath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "skin.xml";
- doc.Load(xmlpath);
- XmlNode xnode = doc.SelectSingleNode("bd");
- XmlElement xe = (XmlElement)xnode["skin"];
- skinbrush.Background = App.Current.FindResource(xe.GetAttribute("name")) as Brush;
- }
- //换肤
- private void btnChangeSkin_Click(object sender, RoutedEventArgs e)
- {
- //显示换肤界面
- skinui.IsOpen = true;
- }
- //反馈
- private void btnFeedback_Click(object sender, RoutedEventArgs e)
- {
- }
- //最小化
- private void btnMin_Click(object sender, RoutedEventArgs e)
- {
- this.WindowState = System.Windows.WindowState.Minimized;
- }
- //主菜单
- private void btnMainMenu_Click(object sender, RoutedEventArgs e)
- {
- }
- //最大化
- private void btnMax_Click(object sender, RoutedEventArgs e)
- {
- if (this.WindowState != System.Windows.WindowState.Maximized)
- {
- this.WindowState = System.Windows.WindowState.Maximized;
- }
- else
- {
- this.WindowState = System.Windows.WindowState.Normal;
- }
- }
- //关闭
- private void btnClose_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- //实现换肤
- private void ChangeSkin(object sender, RoutedEventArgs e)
- {
- Button bt = (Button)sender;
- skinbrush.Background = App.Current.FindResource(bt.Name) as Brush;
- //将选择的皮肤保存到XML文件
- XmlDocument doc = new XmlDocument();
- string xmlpath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "skin.xml";
- doc.Load(xmlpath);
- XmlNode xnode = doc.SelectSingleNode("bd");
- XmlElement xe = (XmlElement)xnode["skin"];
- xe.SetAttribute("name", bt.Name);
- doc.Save(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "skin.xml");
- }
- }
- }
效果如下:
源代码下载:点击打开链接
0 0
- 【.Net码农】WPF界面—仿360安全卫士9.0界面
- WPF界面—仿360安全卫士9.0界面
- (WPF)360安全卫士9.0界面制作过程
- (WPF)360安全卫士9.0界面制作过程
- 【原创】高仿360安全卫士 9.2 界面 (纯qml实现)
- 分享一个使用MUIEditor设计的仿360安全卫士的界面
- (源码)VC开发百分百仿360安全卫士界面,可换肤,可缩放
- WPF库存管理系统界面(仿360UI风格)
- WPF开发实例——仿QQ登录界面
- 纯swing打造360安全卫士界面
- Qt之实现360安全卫士主界面
- Qt实现360安全卫士9.2界面
- QT仿360界面
- 安全卫士第三天 四个界面
- ASP.net--仿网易登录界面
- .NET界面工具WPF Elements中文教程
- .net wpf c#做的计算机界面
- (WPF)360安全卫士界面设计
- UVa 1511 - Soju (思维)
- C++中const用法总结
- C++文件操作详解(ifstream、ofstream、fstream)
- 论C语言的malloc,calloc,new,realloc,alloca的机制和区别
- ubuntu配置android开发所需环境变量
- 【.Net码农】WPF界面—仿360安全卫士9.0界面
- 尹成老师,关于链表的一些操作(C)
- BPMN使用工具
- bootstrap分页
- FKJAVA读书笔记--第八章--JAVA集合
- JVM(3)对象A和B循环引用,最后会不会不被GC回收?-------关于Java的GC机制
- 如何获取结构体某成员的偏移地址
- LeetCode - Valid Sudoku
- Sublime Text3取消自动检查更新