Ejemplo n.º 1
0
        /// <summary>
        /// 在元素已布局、已呈现且可用于交互时发生的事件函数。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                bus.DeviceType[] deviceTypeArray = Application.Current.Properties["DeviceTypeArray"] as bus.DeviceType[];
                if (deviceTypeArray == null)
                    throw new ApplicationException("当前Application缓存查找不到设备类型类表");
                DevTypeCollection devTypeC = new DevTypeCollection();
                devTypeC.initFromDataBusDevTypeArray(deviceTypeArray);
                refreshTreeView(devTypeC);//初始化树拖曳功能

                this.initDropCanvas();//初始化显示面板:将该用户已经监控的设备的对应图标放置在面板上
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 刷新所有数据
 /// </summary>
 public void refreshData()
 {
     string userID = Application.Current.Properties["userID"] as string;
     bus.DataBusServiceClient dataBusServiceClient = new bus.DataBusServiceClient();
     try
     {
         DataBus dataBus1 = new DataBus();
         dataBus1.fillDataBusByRemoteService(dataBusServiceClient,userID);
         //this.dataBus = dataBus1;
         Application.Current.Properties["DataBus"] = dataBus1;
         bus.DeviceType[] deviceTypeArray=dataBusServiceClient.QueryAllDeviceTypeInfo();
         Application.Current.Properties["DeviceTypeArray"] = deviceTypeArray;
         DevTypeCollection devTypeC=new DevTypeCollection();
         devTypeC.initFromDataBusDevTypeArray(deviceTypeArray);
         refreshTreeView(devTypeC);
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message);
         return;
     }
     finally
     {
         if (dataBusServiceClient != null)
             dataBusServiceClient.Close();
         dataBusServiceClient = null;
     }
 }