MainPage.xaml_1121

来源:互联网 发布:libssl dev linux下载 编辑:程序博客网 时间:2024/05/20 04:29

 前台

<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"
    xmlns:local="clr-namespace:ComputerDropDragControl;assembly=ComputerDropDragControl"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <ScrollViewer x:Name="scrollOne"
                      HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
        <Grid x:Name="LayoutRoot" Background="White">
            <StackPanel Orientation="Horizontal">
                <StackPanel x:Name="stackOne" Width="0">
                    <!--<sdk:TreeView >
                        <sdk:TreeViewItem Header="园区">
                            <sdk:TreeViewItem Header="排一">
                            </sdk:TreeViewItem>
                            <sdk:TreeViewItem Header="排二">
                            </sdk:TreeViewItem>
                        </sdk:TreeViewItem>
                    </sdk:TreeView>-->
                </StackPanel>
                <toolkit:ExpressionDarkTheme VerticalAlignment="Top">
                    <StackPanel x:Name="stackTwo" Width="200" >
                        <toolkit:Accordion  Name="accOne" Width="200"
                                            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" Width="100"
                                                VerticalAlignment="Top" Margin="30,0,0,0">
                                    </StackPanel>
                                </toolkit:AccordionItem.Content>
                            </toolkit:AccordionItem>
                        </toolkit:Accordion>
                    </StackPanel>
                </toolkit:ExpressionDarkTheme>
                <!--主题标签开始-->
                <toolkit:ExpressionDarkTheme VerticalAlignment="Top"  HorizontalAlignment="Left">
                    <StackPanel Background="White" >
                        <ScrollViewer x:Name="scrollTwo"  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>
                                <Grid>
                                    <StackPanel x:Name="stackThree">
                                    </StackPanel>
                                    <!--<local:Waiting x:Name="waiting" Visibility="Collapsed" VerticalAlignment="Top"
                                                    HorizontalAlignment="Left"></local:Waiting>-->
                                </Grid>
                            </ScrollViewer.Content>
                        </ScrollViewer>
                    </StackPanel>
                </toolkit:ExpressionDarkTheme>
                <!--主题标签结束-->
            </StackPanel>
            <Border Width="350" Height="120"  CornerRadius="10" Background="#333333" Visibility="Collapsed">
                <!--<toolkit:ShinyRedTheme>-->
                <StackPanel x:Name="stackProgress">
                    <ProgressBar x:Name="progressOne" Height="50" Width="250" Margin="50,20,0,0" >
                    </ProgressBar>
                    <TextBlock x:Name="waitingText" Text="正在加载数据,请稍后....." FontSize="18" Margin="50,10,0,0" Width="250"
                                    Foreground="White"></TextBlock>
                    <StackPanel.Resources>
                        <Storyboard x:Name="storyboard">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="waitingText"
                                                           Storyboard.TargetProperty="Opacity" RepeatBehavior="Forever">
                                <SplineDoubleKeyFrame KeyTime="00:00:0.0" Value="0"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:0.5" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:1.0" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </StackPanel.Resources>
                </StackPanel>
                <!--</toolkit:ShinyRedTheme>-->
            </Border>
        </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;
using GDev.PopupBox;
using System.Windows.Browser;
using System.Net.NetworkInformation;

namespace ComputerDropDragControl
{
    /// <summary>
    /// 机器处理界面
    /// 创建人:吴兆娟
    /// 创建时间:2011-10-24
    /// </summary>
    public partial class MainPage : UserControl
    {
        #region <<页面加载>>

        /// <summary>
        /// 初始化控件
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            StaticClass.ProgressBarStatic = stackProgress;
            StaticClass.UIRoot = LayoutRoot;
            StaticClass.UISB = storyboard;

            //初始化表单
            InitForm();
        }

        /// <summary>
        /// 初始化表单
        /// </summary>
        private void InitForm()
        {
            //设置“最外层滚动条”信息
            double browseWidth = Application.Current.Host.Content.ActualWidth;//SilverLight控件所在浏览器确定的宽度
            double browseHeight = Application.Current.Host.Content.ActualHeight;
            scrollOne.Width = browseWidth - 400;
            scrollOne.Height = browseHeight - 200;
         
            double width = browseWidth;
            double height = browseHeight;
            if (!Application.Current.IsRunningOutOfBrowser)//指示是否从浏览器外状态启动
            {
                //获取浏览器分辨率信息
                ScriptObject screen = (ScriptObject)HtmlPage.Window.GetProperty("screen");
                width = (double)screen.GetProperty("width");
                height = (double)screen.GetProperty("height");
            }

            if (NetworkInterface.GetIsNetworkAvailable())//指示是否有任何可用的网络连接
            {
              
            }


            //设置“滚动条”相关信息
            scrollTwo.Width = width - 200 - 10;
            scrollTwo.Height = height - 12;

            accOne.Height = height - 10;

            #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);

            //“模态窗口”
            Button btn = new Button();
            btn.Content = "回收站";
            btn.Click += new RoutedEventHandler(btn_Click);
            this.stackSystem.Children.Add(btn);

            //“ChildWindow”
            Button btnChildWindow = new Button();
            btnChildWindow.Content = "打开ChildWindow";
            btnChildWindow.Click += new RoutedEventHandler(btnChildWindow_Click);
            this.stackSystem.Children.Add(btnChildWindow);

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

        private void btnChildWindow_Click(object sender, RoutedEventArgs e)
        {
            CWInRack cr = new CWInRack();
            cr.OverlayOpacity = 0.1;
            cr.Height = 300;
            cr.Width = 500;
            //cr.Content = tempFrame;
            try
            {
                cr.Show();
            }
            catch (Exception ex)
            {

            }
        }

        #endregion


        #region <<回收站相关>>

        /// <summary>
        /// “回收站”
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            //弹出“模态信息”窗口
            PopupService service = PopupService.GetServiceFor(LayoutRoot);
            MessagePageWdd box = service.GetMessagePageWdd(
                "置入回收站",
                 new RecyleContent(),
                "回收站",
                true,
                (MessageBoxButtonType)Enum.Parse(
                typeof(MessageBoxButtonType),
                "YesNo",
                true),
                MessageBoxIcon.Information
            );
            box.Effect = GDev.PopupBox.Effect.NoEffect(box);
            box.ShowComplete += new EventHandler(Box_ShowComplete);
            box.ButtonClick += new EventHandler(Box_ButtonClick);
            box.Show();

        }

        private void Box_ButtonClick(object sender, EventArgs e)
        {
            //MessageText.Text = "你点击了:" + ((MessagePage)sender).Result;
        }

        private void Box_ShowComplete(object sender, EventArgs e)
        {
            //MessageText.Text = "打开了新窗口";
        }

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

 

原创粉丝点击