前伴唱
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" x:Class="ComputerDropDragControl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Theme="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<ScrollViewer x:Name="scrollOne" Width="780" Height="720"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Orientation="Horizontal">
<StackPanel x:Name="stackOne" Width="0"></StackPanel>
<toolkit:ExpressionDarkTheme>
<StackPanel x:Name="stackTwo" Width="200" >
<toolkit:Accordion Name="accOne" Width="200" Height="1014"
ExpandDirection="Down" FlowDirection="LeftToRight"
VerticalAlignment="Top" >
<toolkit:AccordionItem Header="设备树" >
<toolkit:AccordionItem.Content>
<StackPanel x:Name="stackTree">
</StackPanel>
</toolkit:AccordionItem.Content>
</toolkit:AccordionItem>
<toolkit:AccordionItem Header="查询">
<toolkit:AccordionItem.Content>
<StackPanel x:Name="stackSearch">
</StackPanel>
</toolkit:AccordionItem.Content>
</toolkit:AccordionItem>
<toolkit:AccordionItem Header="手推车">
<toolkit:AccordionItem.Content>
<StackPanel x:Name="stackHandCar">
</StackPanel>
</toolkit:AccordionItem.Content>
</toolkit:AccordionItem>
<toolkit:AccordionItem Header="系统操作" >
<toolkit:AccordionItem.Content>
<StackPanel x:Name="stackSystem" >
</StackPanel>
</toolkit:AccordionItem.Content>
</toolkit:AccordionItem>
</toolkit:Accordion>
</StackPanel>
</toolkit:ExpressionDarkTheme>
<!--主题标签开始-->
<toolkit:ExpressionDarkTheme VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel Background="White">
<ScrollViewer x:Name="scrollTwo"
HorizontalAlignment="Left" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<!--<ScrollViewer.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Black" Offset="0"></GradientStop>
<GradientStop Color="LightGray" Offset="1"></GradientStop>
</LinearGradientBrush>
</ScrollViewer.Background>-->
<ScrollViewer.Content>
<StackPanel x:Name="stackThree">
</StackPanel>
</ScrollViewer.Content>
</ScrollViewer>
</StackPanel>
</toolkit:ExpressionDarkTheme>
<!--主题标签结束-->
</StackPanel>
</Grid>
</ScrollViewer>
</UserControl>
后半厂
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace ComputerDropDragControl
{
/// <summary>
/// 机器处理界面
/// 创建人:吴兆娟
/// 创建时间:2011-10-24
/// </summary>
public partial class MainPage : UserControl
{
#region <<页面加载>>
/// <summary>
/// 初始化控件
/// </summary>
public MainPage()
{
InitializeComponent();
//初始化表单
InitForm();
}
/// <summary>
/// 初始化表单
/// </summary>
private void InitForm()
{
//设置“滚动条”相关信息
scrollTwo.Width = 1055;
scrollTwo.Height = 1011;
#region <<界面元素>>
//“设备树”
EquipmentTreeView entityTree = new EquipmentTreeView(stackThree);
this.stackTree.Children.Add(entityTree);
//“查询”
SearchPanel entitySearch = new SearchPanel();
this.stackSearch.Children.Add(entitySearch);
//“手推车”
HandCar entityHandCar = new HandCar();
this.stackHandCar.Children.Add(entityHandCar);
//“系统操作”
//“全屏”
FullScreenButton entityFullScreen = new FullScreenButton(scrollOne);
this.stackSystem.Children.Add(entityFullScreen);
//“回收站”
Recyle entityRecyle = new Recyle();
this.stackSystem.Children.Add(entityRecyle);
#endregion
#region <<界面元素>>
添加“设备树”按钮
//Button btnComputerTree = new Button();
//btnComputerTree.Content = "设备树";
//btnComputerTree.Margin = new Thickness(0, 10, 0, 0);
//btnComputerTree.Click += new RoutedEventHandler(btnComputerTree_Click);
//stackOne.Children.Add(btnComputerTree);
添加“全屏按钮”
//FullScreenButton fb = new FullScreenButton(scrollOne);
//fb.Margin = new Thickness(0, 10, 0, 0);
//stackOne.Children.Add(fb);
添加“查询”按钮
//Button btnSearch = new Button();
//btnSearch.Content = "查询";
//btnSearch.Margin = new Thickness(0, 10, 0, 0);
//btnSearch.Click += new RoutedEventHandler(btnSearch_Click);
//stackOne.Children.Add(btnSearch);
添加“手推车”按钮
//Button btnCar = new Button();
//btnCar.Content = "手推车";
//btnCar.Margin = new Thickness(0, 10, 0, 0);
//btnCar.Click += new RoutedEventHandler(btnCar_Click);
//stackOne.Children.Add(btnCar);
添加“回收站”按钮
//Button btnRecyle = new Button();
//btnRecyle.Content = "回收站";
//btnRecyle.Margin = new Thickness(0, 10, 0, 0);
//btnRecyle.Click += new RoutedEventHandler(btnRecyle_Click);
//stackOne.Children.Add(btnRecyle);
#endregion
#region <<默认设置>>
添加EquipmentTreeView
//EquipmentTreeView entity = new EquipmentTreeView(stackThree);
//this.stackTwo.Children.Add(entity);
#endregion
}
#endregion
#region <<控件事件>>
/// <summary>
/// “设备树按钮”点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnComputerTree_Click(object sender, RoutedEventArgs e)
{
Type temp = this.stackTwo.Children[0].GetType();
this.stackTwo.Children.Clear();
//添加EquipmentTreeView
EquipmentTreeView entity = new EquipmentTreeView(stackThree);
this.stackTwo.Children.Add(entity);
if (temp.Name == "EquipmentTreeView")
{
if (stackTwo.Visibility == Visibility.Collapsed)
{
stackTwo.Visibility = Visibility.Visible;
}
else
{
stackTwo.Visibility = Visibility.Collapsed;
}
}
else
{
stackTwo.Visibility = Visibility.Visible;
}
}
/// <summary>
/// “查询按钮”点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
Type temp = this.stackTwo.Children[0].GetType();
this.stackTwo.Children.Clear();
//添加查询界面
SearchPanel entity = new SearchPanel();
this.stackTwo.Children.Add(entity);
if (temp.Name == "SearchPanel")
{
if (stackTwo.Visibility == Visibility.Collapsed)
{
stackTwo.Visibility = Visibility.Visible;
}
else
{
stackTwo.Visibility = Visibility.Collapsed;
}
}
else
{
stackTwo.Visibility = Visibility.Visible;
}
}
/// <summary>
/// “手推车”点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCar_Click(object sender, RoutedEventArgs e)
{
Type temp = this.stackTwo.Children[0].GetType();
this.stackTwo.Children.Clear();
//添加查询界面
HandCar entity = new HandCar();
this.stackTwo.Children.Add(entity);
if (temp.Name == "HandCar")
{
if (stackTwo.Visibility == Visibility.Collapsed)
{
stackTwo.Visibility = Visibility.Visible;
}
else
{
stackTwo.Visibility = Visibility.Collapsed;
}
}
else
{
stackTwo.Visibility = Visibility.Visible;
}
}
/// <summary>
/// “回收站”点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRecyle_Click(object sender, RoutedEventArgs e)
{
Type temp = this.stackTwo.Children[0].GetType();
this.stackTwo.Children.Clear();
//添加查询界面
Recyle entity = new Recyle();
this.stackTwo.Children.Add(entity);
if (temp.Name == "Recyle")
{
if (stackTwo.Visibility == Visibility.Collapsed)
{
stackTwo.Visibility = Visibility.Visible;
}
else
{
stackTwo.Visibility = Visibility.Collapsed;
}
}
else
{
stackTwo.Visibility = Visibility.Visible;
}
}
#endregion
#region <<辅助方法>>
#endregion
}
}