Main后台

来源:互联网 发布:linux arp缓存表 编辑:程序博客网 时间:2024/04/27 06:42
 

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 = 1008;

            #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
    }
}

原创粉丝点击