实例介绍
【实例简介】
仿QQ登录界面
【实例截图】
【核心代码】
<Window x:Class="翻转.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="420" Width="650"
xmlns:local="clr-namespace:翻转"
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
Background="Transparent"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Viewport3D Grid.Row="0" Margin="3">
<Viewport3D.Camera>
<PerspectiveCamera Position="0 0 800" LookDirection="0 0 -1" NearPlaneDistance="100"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ContainerUIElement3D>
<Viewport2DVisual3D>
<Viewport2DVisual3D.Geometry>
<MeshGeometry3D Positions="-200 150 0 -200 -150 0 200 -150 0 200 150 0" TriangleIndices="0 1 2 0 2 3" TextureCoordinates="0 0 0 1 1 1 1 0"/>
</Viewport2DVisual3D.Geometry>
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True"/>
</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Visual>
<local:UcSample1 Width="400" Height="300"/>
</Viewport2DVisual3D.Visual>
</Viewport2DVisual3D>
<Viewport2DVisual3D>
<Viewport2DVisual3D.Geometry>
<MeshGeometry3D Positions="200 150 0 200 -150 0 -200 -150 0 -200 150 0" TriangleIndices="0 1 2 0 2 3" TextureCoordinates="0 0 0 1 1 1 1 0"/>
</Viewport2DVisual3D.Geometry>
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True"/>
</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Visual>
<local:UcSample2 Width="400" Height="300"/>
</Viewport2DVisual3D.Visual>
</Viewport2DVisual3D>
<!-- 三维变换 -->
<ContainerUIElement3D.Transform>
<RotateTransform3D CenterX="0.5" CenterY="0.5" CenterZ="0.5">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="axr" Angle="0" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</ContainerUIElement3D.Transform>
</ContainerUIElement3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="Transparent"/>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
</Grid>
</Window>
代码部分
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;
namespace 翻转
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public static MainWindow my;
public bool[] cg;
public MainWindow()
{
InitializeComponent();
MainWindow.my = this;
}
public MainWindow(ref bool[] cg)
{
InitializeComponent();
MainWindow.my = this;
this.cg = cg;
}
public void OnClick(int s)
{
switch (s)
{
case 0:
this.Close();
break;
case 1:
DoubleAnimation da = new DoubleAnimation();
da.Duration = new Duration(TimeSpan.FromSeconds(1));
da.To = 0d;
this.axr.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
break;
case 2:
da = new DoubleAnimation();
da.Duration = new Duration(TimeSpan.FromSeconds(1));
da.To = 180d;
this.axr.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
break;
}
}
}
}
<UserControl x:Class="翻转.UcSample1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="500">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="背景.png"/>
</Grid.Background>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Text="用户登录" FontSize="42" FontFamily="华文行楷" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Grid Margin="5" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Text="用户名:" FontSize="24" VerticalAlignment="Center"/>
<TextBox Name="tex1" Grid.Column="1" Grid.Row="0" Margin="3,4,16,4" FontSize="24"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="密码:" FontSize="24" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<PasswordBox Name="tex2" Grid.Column="1" Grid.Row="1" Margin="3,4,16,4" FontSize="24"/>
</Grid>
<Grid Grid.Row="2" MouseDown="Grid_MouseDown_2" HorizontalAlignment="Center" Margin="0,15,0,15" Width="180" Height="36">
<Grid.Background>
<ImageBrush ImageSource="登录.png"/>
</Grid.Background>
</Grid>
</Grid>
<Grid Name="mygrid1" HorizontalAlignment="Right" Margin="0,4,4,0" Height="16" VerticalAlignment="Top" Width="16" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" Background="#07BDCFFF" MouseDown="Grid_MouseDown">
<!--<Polygon Name="p1" Points="0,0,10,18,50,18,60,0" Fill="White" StrokeThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" StrokeLineJoin="Miter" />-->
<Line Name="line1" X1="1" Y1="1" X2="15" Y2="15" Stroke="Black" StrokeThickness="2" />
<Line Name="line2" X1="15" Y1="1" X2="1" Y2="15" Stroke="Black" StrokeThickness="2" />
<!--<Line X1="50" Y1="18" X2="60" Y2="0" Stroke="Black" StrokeThickness="1" />-->
</Grid>
<Grid Name="mygrid2" HorizontalAlignment="Right" Margin="0,2,26,0" Height="20" VerticalAlignment="Top" Width="20" MouseEnter="Grid_MouseEnter_1" MouseDown="Grid_MouseDown_1">
<Grid.Background>
<ImageBrush ImageSource="设置.png"/>
</Grid.Background>
</Grid>
<Grid HorizontalAlignment="Left" Margin="2,2,26,0" Height="20" VerticalAlignment="Top" Width="20" >
<Grid.Background>
<ImageBrush ImageSource="登录图标(1).png"/>
</Grid.Background>
</Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace 翻转
{
/// <summary>
/// UcSample1.xaml 的交互逻辑
/// </summary>
public partial class UcSample1 : UserControl
{
private Brush mygrid1_Background;
public UcSample1()
{
InitializeComponent();
this.mygrid1_Background = this.mygrid1.Background;
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
MainWindow.my.OnClick(0);
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
this.line1.Stroke = Brushes.Red;
this.line2.Stroke = Brushes.Red;
this.mygrid1.Background = Brushes.White;
}
private void Grid_MouseDown_1(object sender, MouseButtonEventArgs e)
{
MainWindow.my.OnClick(2);
}
private void Grid_MouseEnter_1(object sender, MouseEventArgs e)
{
}
private void Grid_MouseLeave(object sender, MouseEventArgs e)
{
this.line1.Stroke = Brushes.Black;
this.line2.Stroke = Brushes.Black;
this.mygrid1.Background = mygrid1_Background;
}
private void Grid_MouseDown_2(object sender, MouseButtonEventArgs e)
{
if (tex1.Text == "1" && tex2.Password == "111111")
{
MainWindow.my.cg[0] = true;
MainWindow.my.OnClick(0);
}
else
{
MessageBox.Show("用户名=1;密码=111111");
}
}
}
}
<UserControl x:Class="翻转.UcSample2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="500">
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#FF7367E6" Offset="0"/>
<GradientStop Color="#FF789AF3" Offset="1"/>
<GradientStop Color="#FFD5CCF7" Offset="0.558"/>
</LinearGradientBrush>
</Grid.Background>
<Canvas Margin="20" SnapsToDevicePixels="True">
<TextBlock Text="连接方式:" FontSize="22"/>
<StackPanel Orientation="Vertical" Canvas.Top="36">
<RadioButton GroupName="g" Content="TCP" FontSize="20"/>
<RadioButton GroupName="g" Content="UDP" FontSize="20"/>
</StackPanel>
<GroupBox Canvas.Top="120" Header="设置代理">
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="IP地址:" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Width="150" Margin="5"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="端口:" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="1" Width="150" Margin="5"/>
</Grid>
</GroupBox>
</Canvas>
<Grid Name="mygrid1" HorizontalAlignment="Right" Margin="0,4,4,0" Height="16" VerticalAlignment="Top" Width="16" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" Background="#07BDCFFF" MouseDown="Grid_MouseDown">
<!--<Polygon Name="p1" Points="0,0,10,18,50,18,60,0" Fill="White" StrokeThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" StrokeLineJoin="Miter" />-->
<Line Name="line1" X1="1" Y1="1" X2="15" Y2="15" Stroke="Black" StrokeThickness="2" />
<Line Name="line2" X1="15" Y1="1" X2="1" Y2="15" Stroke="Black" StrokeThickness="2" />
<!--<Line X1="50" Y1="18" X2="60" Y2="0" Stroke="Black" StrokeThickness="1" />-->
</Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace 翻转
{
/// <summary>
/// UcSample2.xaml 的交互逻辑
/// </summary>
public partial class UcSample2 : UserControl
{
private Brush mygrid1_Background;
public UcSample2()
{
InitializeComponent();
this. mygrid1_Background = this.mygrid1.Background;
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
MainWindow.my.OnClick(1);
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
this.line1.Stroke = Brushes.Red;
this.line2.Stroke = Brushes.Red;
this.mygrid1.Background = Brushes.White;
}
private void Grid_MouseLeave(object sender, MouseEventArgs e)
{
this.line1.Stroke = Brushes.Black;
this.line2.Stroke = Brushes.Black;
this.mygrid1.Background = mygrid1_Background;
}
}
}
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论