using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace Picture
{
public class MyCommand
{
//最小化命令
public static RoutedCommand SmallCommand = new RoutedCommand();
//最大化命令
public static RoutedCommand BigCommand = new RoutedCommand();
//正常窗口命令
public static RoutedCommand NormalCommand = new RoutedCommand();
//关闭命令
public static RoutedCommand CloseCommand = new RoutedCommand();
//开始自定义命令
public static RoutedCommand UpCommand = new RoutedCommand();
//前一张图片
public static RoutedCommand BeforeCommand = new RoutedCommand();
//后一张图片
public static RoutedCommand AfterCommand = new RoutedCommand();
//顺时针旋转
public static RoutedCommand ClockwiseCommand = new RoutedCommand();
//逆时针旋转
public static RoutedCommand AntiClockwiseCommand = new RoutedCommand();
//左右翻转
public static RoutedCommand LeftAndRightCommand = new RoutedCommand();
//上下翻转
public static RoutedCommand AboveAndBelowCommand = new RoutedCommand();
//放大图片
public static RoutedCommand AmplificationCommand = new RoutedCommand();
//缩小图片
public static RoutedCommand NarrowCommand = new RoutedCommand();
//幻灯片播放
public static RoutedCommand SlideCommand = new RoutedCommand();
//打开文件
public static RoutedCommand OpenFileCommand = new RoutedCommand();
//设置
public static RoutedCommand SetCommand = new RoutedCommand();
//向左移动
public static RoutedCommand LeftCommand = new RoutedCommand();
//向右移动
public static RoutedCommand RightCommand = new RoutedCommand();
//主题设置
public static RoutedCommand ThemeCommand = new RoutedCommand();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Interop;
using Microsoft.Win32;
using System.Xml;
using System.Diagnostics;
using System.Collections;
using System.IO;
namespace Picture
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public class LVData
{
public string Pic
{
get;
set;
}
}
bool bHelp = true;
List<LVData> ListPicture = new List<LVData>();
public MainWindow()
{
InitializeComponent();
LVData iamgebrush1 = new LVData();
//iamgebrush1.Pic = "D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png";
//ListPicture.Add(iamgebrush1);
//LVData iamgebrush2 = new LVData();
//iamgebrush2.Pic = "D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png";
//ListPicture.Add(iamgebrush2);
//ImageBrush iamgebrush3 = new ImageBrush();
//iamgebrush3.ImageSource = new BitmapImage(new Uri("D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png"));
//iamgebrush3.Stretch = Stretch.UniformToFill;
//list.Add(iamgebrush3);
//ImageBrush iamgebrush4 = new ImageBrush();
//iamgebrush4.ImageSource = new BitmapImage(new Uri("D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png"));
//iamgebrush4.Stretch = Stretch.UniformToFill;
//list.Add(iamgebrush4);
//ImageBrush iamgebrush5 = new ImageBrush();
//iamgebrush5.ImageSource = new BitmapImage(new Uri("D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png"));
//iamgebrush5.Stretch = Stretch.UniformToFill;
//list.Add(iamgebrush5);
//ImageBrush iamgebrush6 = new ImageBrush();
//iamgebrush6.ImageSource = new BitmapImage(new Uri("D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png"));
//iamgebrush6.Stretch = Stretch.UniformToFill;
//list.Add(iamgebrush6);
//LVPicture.ItemsSource = ListPicture;
//ImageBrush iamgebrush = new ImageBrush();
//iamgebrush.ImageSource = new BitmapImage(new Uri("D:\\Protect2010\\Picture\\Picture\\Images\\backimage.png"));
//iamgebrush.Stretch = Stretch.UniformToFill;
//this.Background = iamgebrush;
//DesignerHead.Visibility = Visibility.Hidden;
double height = SystemParameters.WorkArea.Height;
double width = SystemParameters.WorkArea.Width;
this.Top = (height - this.Height) / 2;
this.Left = (width - this.Width) / 2;
XmlDocument doc = new XmlDocument();
doc.Load("..\\..\\Configure.xml");
//if (doc == null)
//{
// MessageBox.Show("null");
//}
//else
//{
// XmlNode xn = doc.SelectSingleNode("Configure/zhutua");
// bHelp = Convert.ToBoolean(xn.InnerText.ToString());
//}
//if (bHelp)
//{
// SPanel.Visibility = Visibility.Visible;
// PathName.Visibility = Visibility.Visible;
//}
//else
//{
// SPanel.Visibility = Visibility.Hidden;
// PathName.Visibility = Visibility.Hidden;
//}
//Page4 page = new Page4();
//frame1.Navigate(page);
Page4 page = new Page4();
frame1.Navigate(page);
//frame1.Navigate(new Uri("Page1.xaml", UriKind.Relative));
}
private void CloseWindow(object sender, RoutedEventArgs e)
{
this.Close();
}
private void DragWindow(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
{
hwndSource.AddHook(new HwndSourceHook(this.WndProc));
}
else
{
MessageBox.Show("df");
}
}
//protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
//{
// return IntPtr.Zero;
//}
private const int WM_NCHITTEST = 0x0084;
private readonly int agWidth = 12; //拐角宽度
private readonly int bThickness = 4; // 边框宽度
private Point mousePoint = new Point(); //鼠标坐标
protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (WM_NCHITTEST == msg)
{
this.mousePoint.X = (lParam.ToInt32() & 0xFFFF);
this.mousePoint.Y = (lParam.ToInt32() >> 16);
// 窗口左上角
if (this.mousePoint.Y - this.Top <= this.agWidth
&& this.mousePoint.X - this.Left <= this.agWidth)
{
handled = true;
return new IntPtr((int)HitTest.HTTOPLEFT);
}
// 窗口左下角
else if (this.ActualHeight + this.Top - this.mousePoint.Y <= this.agWidth
&& this.mousePoint.X - this.Left <= this.agWidth)
{
handled = true;
return new IntPtr((int)HitTest.HTBOTTOMLEFT);
}
// 窗口右上角
else if (this.mousePoint.Y - this.Top <= this.agWidth
&& this.ActualWidth + this.Left - this.mousePoint.X <= this.agWidth)
{
handled = true;
return new IntPtr((int)HitTest.HTTOPRIGHT);
}
// 窗口右下角
else if (this.ActualWidth + this.Left - this.mousePoint.X <= this.agWidth
&& this.ActualHeight + this.Top - this.mousePoint.Y <= this.agWidth)
{
handled = true;
return new IntPtr((int)HitTest.HTBOTTOMRIGHT);
}
// 窗口左侧
else if (this.mousePoint.X - this.Left <= this.bThickness)
{
handled = true;
return new IntPtr((int)HitTest.HTLEFT);
}
// 窗口右侧
else if (this.ActualWidth + this.Left - this.mousePoint.X <= this.bThickness)
{
handled = true;
return new IntPtr((int)HitTest.HTRIGHT);
}
// 窗口上方
else if (this.mousePoint.Y - this.Top <= this.bThickness)
{
handled = true;
return new IntPtr((int)HitTest.HTTOP);
}
// 窗口下方
else if (this.ActualHeight + this.Top - this.mousePoint.Y <= this.bThickness)
{
handled = true;
return new IntPtr((int)HitTest.HTBOTTOM);
}
else // 窗口移动
{
handled = false;
return new IntPtr();// ((int)HitTest.HTCAPTION);
}
}
return IntPtr.Zero;
}
public enum HitTest:int
{
HTERROR = -2,
HTTRANSPARENT = -1,
HTNOWHERE = 0,
HTCLIENT = 1,
HTCAPTION = 2,
HTSYSMENU = 3,
HTGROWBOX = 4,
HTSIZE = HTGROWBOX,
HTMENU = 5,
HTHSCROLL = 6,
HTVSCROLL = 7,
HTMINBUTTON = 8,
HTMAXBUTTON = 9,
HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17,
HTBORDER = 18,
HTREDUCE = HTMINBUTTON,
HTZOOM = HTMAXBUTTON,
HTSIZEFIRST = HTLEFT,
HTSIZELAST = HTBOTTOMRIGHT,
HTOBJECT = 19,
HTCLOSE = 20,
HTHELP = 21,
}
private void OpenFile(object sender, ExecutedRoutedEventArgs e)
{
OpenFileDialog myDialog = new OpenFileDialog();
myDialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF" +
"|All files (*.*)|*.*";
myDialog.CheckFileExists = true;
myDialog.Multiselect = true;
//DesignerHead.Visibility = Visibility.Visible;
if (myDialog.ShowDialog() == true)
{
//MessageBox.Show(myDialog.FileNames.First());
BitmapImage Bimage = new BitmapImage(new Uri(myDialog.FileNames.First(), UriKind.Absolute));
DesignerHead.Source = Bimage;
}
}
private void CloseApp(object sender, ExecutedRoutedEventArgs e)
{
this.Close();
}
private void cmdClose_Click(object sender, RoutedEventArgs e)
{
//SPanel.Visibility = Visibility.Hidden;
//PathName.Visibility = Visibility.Hidden;
XmlDocument doc = new XmlDocument();
doc.Load("..\\..\\Configure.xml");
if (doc == null)
{
MessageBox.Show("null");
}
else
{
XmlNode xn = doc.SelectSingleNode("Configure/zhutua");
xn.InnerText = "false";
doc.Save("..\\..\\Configure.xml");
}
}
//int IAngle = 0;
private void button3_Click(object sender, RoutedEventArgs e)
{
//if (IAngle > 360)
//{
// IAngle = 0;
//}
//else
//{
// IAngle += 90;
//}
//RotateTransform rotateTransform = new RotateTransform(IAngle);
//DesignerHead.RenderTransform = rotateTransform;
}
private void button4_Click(object sender, RoutedEventArgs e)
{
//if (IAngle < -360)
//{
// IAngle = 0;
//}
//else
//{
// IAngle -= 90;
//}
//RotateTransform rotateTransform = new RotateTransform(IAngle);
//DesignerHead.RenderTransform = rotateTransform;
}
//int IScalex = -1;
private void button5_Click(object sender, RoutedEventArgs e)
{
////RenderTransformOrigin
//DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
//ScaleTransform scaleTransform = new ScaleTransform();
//scaleTransform.ScaleX = IScalex;
////scaleTransform.ScaleY = 1.2;
////scaleTransform.CenterX = 0; // DesignerHead.Width / 2;
////scaleTransform.CenterY = 0; // DesignerHead.Height / 2;
//if (-1 == IScalex)
//{
// IScalex = 1;
//}
//else
//{
// IScalex = -1;
//}
//DesignerHead.RenderTransform = scaleTransform;
}
//int IScaley = -1;
private void button6_Click(object sender, RoutedEventArgs e)
{
//DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
//ScaleTransform scaletransform = new ScaleTransform();
//scaletransform.ScaleY = IScaley;
//if (-1 == IScaley)
//{
// IScaley = 1;
//}
//else
//{
// IScaley = -1;
//}
//DesignerHead.RenderTransform = scaletransform;
}
private bool m_IsMouseLeftButtonDown;
private void MasterImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Rectangle rectangle = sender as Rectangle;
if (rectangle == null)
return;
rectangle.ReleaseMouseCapture();
m_IsMouseLeftButtonDown = false;
}
private Point m_PreviousMousePoint;
private void MasterImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Rectangle rectangle = sender as Rectangle;
if (rectangle == null)
return;
rectangle.CaptureMouse();
m_IsMouseLeftButtonDown = true;
m_PreviousMousePoint = e.GetPosition(rectangle);
}
private void MasterImage_MouseMove(object sender, MouseEventArgs e)
{
Rectangle rectangle = sender as Rectangle;
if (rectangle == null)
return;
if (m_IsMouseLeftButtonDown)
DoImageMove(rectangle, e);
}
private void DoImageMove(Rectangle rectangle, MouseEventArgs e)
{
//Debug.Assert(e.LeftButton == MouseButtonState.Pressed);
if (e.LeftButton != MouseButtonState.Pressed)
return;
TransformGroup group = MainPanel.FindResource("ImageTransformResource") as TransformGroup;
Debug.Assert(group != null);
TranslateTransform transform = group.Children[1] as TranslateTransform;
Point position = e.GetPosition(rectangle);
transform.X += position.X - m_PreviousMousePoint.X;
transform.Y += position.Y - m_PreviousMousePoint.Y;
m_PreviousMousePoint = position;
}
private void MasterImage_MouseWheel(object sender, MouseWheelEventArgs e)
{
TransformGroup group = MainPanel.FindResource("ImageTransformResource") as TransformGroup;
Debug.Assert(group != null);
ScaleTransform transform = group.Children[0] as ScaleTransform;
DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
transform.CenterX = this.Width / 2;
transform.CenterY = this.Height / 2;
transform.ScaleX += e.Delta * 0.001;
transform.ScaleY += e.Delta * 0.001;
}
//主题更替
private void ThemeCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("主题更替");
}
//最小化命令
private void SmallCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
this.WindowState = System.Windows.WindowState.Minimized;
}
Button btnBig = new Button();
Button btnSmall = new Button();
bool IsNormal = true;
//最大化命令
private void BigCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
//正常窗口到最大化
if (IsNormal)
{
this.WindowState = System.Windows.WindowState.Maximized;
IsNormal = false;
Button btn = e.OriginalSource as Button;
btnBig = btn;
btn.Content = "正 常";
}
else
{
this.WindowState = System.Windows.WindowState.Normal;
IsNormal = true;
Button btn = e.OriginalSource as Button;
btnBig = btn;
btn.Content = "最大化";
}
}
//正常窗口命令
private void NormalCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Button btn = e.OriginalSource as Button;
btnSmall = btn;
btn.Visibility = Visibility.Hidden;
btnBig.Visibility = Visibility.Visible;
this.WindowState = System.Windows.WindowState.Normal;
Page2 page = new Page2();
page.WindowHeight = this.Height;
page.WindowWidth = this.Width;
}
//关闭命令
private void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
this.Close();
}
int IAngle = 0;
//顺时针翻转
private void ClockwiseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
if (IAngle > 360)
{
IAngle = 0;
}
else
{
IAngle += 90;
}
RotateTransform rotateTransform = new RotateTransform(IAngle);
DesignerHead.RenderTransform = rotateTransform;
}
//逆时针翻转
private void AntiClockwiseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
if (IAngle < -360)
{
IAngle = 0;
}
else
{
IAngle -= 90;
}
RotateTransform rotateTransform = new RotateTransform(IAngle);
DesignerHead.RenderTransform = rotateTransform;
}
int IScalex = -1;
//左右翻转
private void LeftAndRightCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
ScaleTransform scaleTransform = new ScaleTransform();
scaleTransform.ScaleX = IScalex;
//scaleTransform.ScaleY = 1.2;
//scaleTransform.CenterX = 0; // DesignerHead.Width / 2;
//scaleTransform.CenterY = 0; // DesignerHead.Height / 2;
if (-1 == IScalex)
{
IScalex = 1;
}
else
{
IScalex = -1;
}
DesignerHead.RenderTransform = scaleTransform;
}
int IScaley = -1;
//上下翻转
private void AboveAndBelowCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
DesignerHead.RenderTransformOrigin = new Point(0.5, 0.5);
ScaleTransform scaletransform = new ScaleTransform();
scaletransform.ScaleY = IScaley;
if (-1 == IScaley)
{
IScaley = 1;
}
else
{
IScaley = -1;
}
DesignerHead.RenderTransform = scaletransform;
}
//放大图片
private void AmplificationCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("放大图片");
}
//缩小图片
private void NarrowCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("缩小图片");
}
//前一张图片
private void BeforeCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("前一张图片");
}
//后一张图片
private void AfterCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("后一张图片");
}
//幻灯片播放
private void SlideCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("幻灯片播放");
}
//打开文件
private void OpenFileCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
OpenFileDialog myDialog = new OpenFileDialog();
myDialog.Filter = "Image Files(*.png;*.BMP;*.JPG;*.GIF)|*png;*.BMP;*.JPG;*.GIF" +
"|All files (*.*)|*.*";
myDialog.CheckFileExists = true;
myDialog.Multiselect = true;
//DesignerHead.Visibility = Visibility.Visible;
if (myDialog.ShowDialog() == true)
{
DateTime date1 = DateTime.Now;
//MessageBox.Show(myDialog.FileNames.First());
BitmapImage Bimage = new BitmapImage(new Uri(myDialog.FileNames.First(), UriKind.Absolute));
string FileName = myDialog.SafeFileName;
string Files = myDialog.FileNames.First().Replace(FileName, "");
string[] sFileNames = Directory.GetFiles(Files);
foreach (string File in sFileNames)
{
LVData lvdata = new LVData();
lvdata.Pic = File;
ListPicture.Add(lvdata);
}
DesignerHead.Source = Bimage;
//LVPicture.ItemsSource = ListPicture;
DateTime date2 = DateTime.Now;
DateTime date3 = DateTime.Now;
}
}
//设置属性
private void SetCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("设置属性");
}
//左移图片
private void LeftCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("左移图片");
}
//右移图片
private void RightCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("右移图片");
}
private void clickdouble(object sender, MouseButtonEventArgs e)
{
this.WindowState = System.Windows.WindowState.Maximized;
}
bool bMove = false;
private void MainPanel_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//bMove = true;
}
private void MainPanel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
// bMove = false;
}
private void MainPanel_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (bMove)
{
// this.DragMove();
}
}
}
}
<Window x:Class="Picture.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local ="clr-namespace:Picture"
Title="MainWindow" Height="500" Width="600" WindowStyle="None" AllowsTransparency="True"
MouseWheel="MasterImage_MouseWheel"
MouseLeftButtonDown="DragWindow" BorderBrush="#FF9E2020" MouseDoubleClick="clickdouble" MinWidth="600" MinHeight="500">
<Window.Background>
<ImageBrush ImageSource="/Picture;component/Images/backimage.png" Stretch="None" TileMode="FlipXY" Viewport="0,0,23.9970001156186,20.9973751011662" ViewportUnits="Absolute" />
</Window.Background>
<Window.CommandBindings>
<CommandBinding Command="{x:Static local:MyCommand.ThemeCommand}" Executed="ThemeCommand_Executed"></CommandBinding>
<CommandBinding Command="Open" Executed="OpenFile"></CommandBinding>
<CommandBinding Command="Close" Executed="CloseApp"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.SmallCommand}" Executed="SmallCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.NormalCommand}" Executed="NormalCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.BigCommand}" Executed="BigCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.CloseCommand}" Executed="CloseCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.ClockwiseCommand}" Executed="ClockwiseCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.AntiClockwiseCommand}" Executed="AntiClockwiseCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.LeftAndRightCommand}" Executed="LeftAndRightCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.AboveAndBelowCommand}" Executed="AboveAndBelowCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.AmplificationCommand}" Executed="AmplificationCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.NarrowCommand}" Executed="NarrowCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.BeforeCommand}" Executed="BeforeCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.AfterCommand}" Executed="AfterCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.SlideCommand}" Executed="SlideCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.OpenFileCommand}" Executed="OpenFileCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.SetCommand}" Executed="SetCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.LeftCommand}" Executed="LeftCommand_Executed"></CommandBinding>
<CommandBinding Command="{x:Static local:MyCommand.RightCommand}" Executed="RightCommand_Executed"></CommandBinding>
</Window.CommandBindings>
<Window.Resources>
<Storyboard x:Key="LoadHeadStoryboard">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="DesignerHead" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame Value="1"/>
<SplineDoubleKeyFrame Value="-1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Rectangle x:Name="Rectangle"
Stroke="#FFFFFFFF"
StrokeMiterLimit="1.000000"
StrokeThickness="0.500000"
RadiusX="10"
RadiusY="10"
Fill="#FF777777">
</Rectangle>
<ContentPresenter x:Name="ContentPresenter"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="Rectangle">
<Setter.Value>
<SolidColorBrush Color="White"></SolidColorBrush>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="MouseDown">
<BeginStoryboard Storyboard="{StaticResource LoadHeadStoryboard}"/>
</EventTrigger>
</Window.Triggers>
<!-- 窗体中的内容 -->
<Grid x:Name="MainPanel" PreviewMouseLeftButtonUp="MainPanel_PreviewMouseLeftButtonUp" PreviewMouseMove="MainPanel_PreviewMouseMove" PreviewMouseLeftButtonDown="MainPanel_PreviewMouseLeftButtonDown" >
<Grid.Resources>
<TransformGroup x:Key="ImageTransformResource">
<ScaleTransform />
<TranslateTransform />
</TransformGroup>
</Grid.Resources>
<Rectangle x:Name="MasterImage"
MouseLeftButtonDown="MasterImage_MouseLeftButtonDown"
MouseLeftButtonUp="MasterImage_MouseLeftButtonUp"
MouseMove="MasterImage_MouseMove"
MouseWheel="MasterImage_MouseWheel">
<Rectangle.Fill>
<VisualBrush Transform="{StaticResource ImageTransformResource}" Stretch="Uniform">
<VisualBrush.Visual>
<Image Name="DesignerHead" HorizontalAlignment="Left" Margin="16,16,0,0" Stretch="Fill" VerticalAlignment="Top" Source="/Picture;component/Images/Lighthouse.jpg" />
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>
<ListView Name="LVPicture" Width="400" Height="100" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="96,0,82,70">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Image Width="30" Height="30" Source="{Binding Pic}"></Image>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListView>
<!--<Image RenderTransformOrigin="0.4,0.5" HorizontalAlignment="Center" x:Name="DesignerHead" Stretch="Fill" VerticalAlignment="Center" Source="/Picture;component/Images/Desert%20-%20副本%20-%20副本%20%289%29%20-%20副本.jpg" Width="284" Margin="0" Height="351">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup>
</Image.RenderTransform>
</Image>-->
<!-- 窗体的边框,底色设置,
注意将CornerRadius与左上角“X”叉形按钮的设置保持一致或约大于叉形按钮的RadiusX/Y设置 -->
<!--<Border CornerRadius="0,0,0,0" Background="Transparent" BorderBrush="Aqua" BorderThickness="1">
<Frame Name="frame1" Background="Transparent" BorderBrush="Red" BorderThickness="5" />
</Border>-->
<Frame Name="frame1"></Frame>
<!--左上角的“X”叉形按钮-->
<!--<Button Name="Button1"
Command="Close"
Style="{StaticResource ButtonStyle}"
Width="15"
Height="15"
Content="X"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,25,27,0"></Button>-->
<!--<Path Name="PathName" Stroke="DarkGray" StrokeThickness="1" SnapsToDevicePixels="True" Data="M20,0 L140,0 A20,20,0,0,1,160,20 L160,60 A20,20,0,0,1,140,80 L70,80 L70,130 L40,80 L20,80 A20,20,0,0,1,0,60 L0,20 A20,20,0,0,1,20,0 z" Margin="144,43,194,135">
<Path.Fill>
<LinearGradientBrush StartPoint="0.2,0" EndPoint="0.8,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="White" Offset="0"></GradientStop>
<GradientStop Color="White" Offset="0.45"></GradientStop>
<GradientStop Color="LightBlue" Offset="0.9"></GradientStop>
<GradientStop Color="Gray" Offset="1"></GradientStop>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Path.Fill>
<Path.RenderTransform>
<ScaleTransform ScaleX="1.3" ScaleY="1.3"></ScaleTransform>
</Path.RenderTransform>
</Path>
<StackPanel Name="SPanel" Margin="154,46,161,95">
<Button HorizontalAlignment="Right" Click="cmdClose_Click" Margin="0,5,10,0" >
x
</Button><TextBlock TextWrapping="Wrap" FontSize="15" HorizontalAlignment="Center">Open File</TextBlock>
</StackPanel>
<Button Command="Open" Content="{Binding RelativeSource={RelativeSource Self},Path=Command.Text}" Height="23" HorizontalAlignment="Left" Margin="207,218,0,0" Name="button2" VerticalAlignment="Top" Width="75" />-->
<!--<Button Content="上一页" Height="23" HorizontalAlignment="Left" Margin="26,275,0,0" Name="button3" VerticalAlignment="Top" Width="75" Command="{x:Static local:MyCommand.UpCommand}" />
<Button Content="下一页" Height="23" HorizontalAlignment="Left" Margin="117,275,0,0" Name="button4" VerticalAlignment="Top" Width="75" Click="button4_Click" />
<Button Content="左右翻转" Height="23" HorizontalAlignment="Left" Margin="214,275,0,0" Name="button5" VerticalAlignment="Top" Width="75" Click="button5_Click" />
<Button Content="上下翻转" Height="23" HorizontalAlignment="Left" Margin="309,275,0,0" Name="button6" VerticalAlignment="Top" Width="75" Click="button6_Click" />-->
<!--<Rectangle x:Name="MasterImage"
MouseLeftButtonDown="MasterImage_MouseLeftButtonDown"
MouseLeftButtonUp="MasterImage_MouseLeftButtonUp"
MouseMove="MasterImage_MouseMove"
MouseWheel="MasterImage_MouseWheel" Width="30" Height="30">
<Rectangle.Fill>
<VisualBrush Transform="{StaticResource ImageTransformResource}" Stretch="Uniform">
<VisualBrush.Visual>
<Image Height="1" Name="DesignerHead" HorizontalAlignment="Left" Margin="16,16,0,0" Stretch="Fill" VerticalAlignment="Top" Width="1" Source="/Picture;component/Images/Lighthouse.jpg" />
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>-->
</Grid>
</Window>