Example #1
0
        /// <summary>
        /// 分站电源箱label点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubstationLabelClick(object sender, EventArgs e)
        {
            try
            {
                var tv = (Label)sender;
                var bi = (BatteryItem)tv.Tag;
                //label2.Text = bi.BatteryAddress;
                label2.Text = bi.Channel;

                _lisDef = ControlInterfaceFuction.GetAllSubstation();//重新加载
                string     selectStationPointId = "";
                Jc_DefInfo def = _lisDef.Find(a => a.Fzh == short.Parse(selectFzhNow));
                if (def != null)
                {
                    selectStationPointId = def.PointID;
                }
                //查找分站对应的电源箱5分钟统计信息
                BatteryPowerConsumption batteryPowerConsumption = new BatteryPowerConsumption();
                if (def.BatteryPowerConsumptions != null)
                {
                    batteryPowerConsumption = def.BatteryPowerConsumptions.Find(a => a.Channel == bi.Channel);
                }
                var tempCharge = new CuCharge(bi, batteryPowerConsumption);
                //CpanelPowerPac.Controls.Clear();
                //重写释放控件的方法,直接clear会导致句柄资源一直增加  20180422
                while (CpanelPowerPac.Controls.Count > 0)
                {
                    if (CpanelPowerPac.Controls[0] != null)
                    {
                        CpanelPowerPac.Controls[0].Dispose();
                    }
                }
                CpanelPowerPac.Controls.Add(tempCharge);
                tempCharge.Dock = DockStyle.Fill;

                //var node = treeViewSubstation.SelectedNode;
                //Dictionary<string, object> dic = new Dictionary<string, object>();
                //dic.Add("GetBatteryItem", ((Label)sender).Text);
                //dic.Add("SelNode", node);
                //_refStationBattery = new Thread(GetBatteryItem);

                //_refStationBattery.Start(dic);
            }
            catch (Exception exc)
            {
                XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #2
0
        //private void GetBatteryItem(object dic)
        //{
        //    Dictionary<string, object> tempdic = dic as Dictionary<string, object>;
        //    string batteryAddress = tempdic["GetBatteryItem"].ToString();
        //    var node = (TreeNode)tempdic["SelNode"];
        //    if (node == null)
        //    {
        //        return;
        //    }
        //    var gsa = ControlInterfaceFuction.GetSubstationPowerBoxInfo(node.Name);

        //    if (gsa.PowerDateTime > Convert.ToDateTime("1900-01-01"))
        //    {
        //        BatteryItem item = gsa.PowerBoxInfo.FirstOrDefault(a => a.Channel == batteryAddress.ToString());
        //        if (item != null)
        //        {
        //            //Action<object> act = RefStationBatteryInfo;
        //            //BeginInvoke(act, item);
        //            MethodInvoker In = new MethodInvoker(() => RefStationBatteryInfo(item));
        //            if (this.InvokeRequired)
        //            {
        //                this.BeginInvoke(In);
        //            }
        //            //_substationUpdatetime[node.Name] = gsa.PowerDateTime;
        //            //substationUpdatetime.Text = _substationUpdatetime[node.Name].ToString("yyyy-MM-dd HH:mm:ss");
        //        }
        //    }
        //}

        //private void RefStationBatteryInfo(object item)
        //{
        //    var tempCharge = new CuCharge((BatteryItem)item);
        //    CpanelPowerPac.Controls.Clear();
        //    CpanelPowerPac.Controls.Add(tempCharge);
        //    tempCharge.Dock = DockStyle.Fill;

        //    //substationUpdatetime.Text = PowerDateTime.ToString();
        //}

        /// <summary>
        /// 交换机电源箱label点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SwitchLabelClick(object sender, EventArgs e)
        {
            try
            {
                var tv = (Label)sender;
                var bi = (BatteryItem)tv.Tag;
                label3.Text = bi.Channel;

                //加载交换机
                _lisMac = ControlInterfaceFuction.GetAllSwitch();

                Jc_MacInfo mac = _lisMac.Find(a => a.MAC == selectMacNow);

                //查找分站对应的电源箱5分钟统计信息
                BatteryPowerConsumption batteryPowerConsumption = new BatteryPowerConsumption();
                if (mac.BatteryPowerConsumptions != null)
                {
                    batteryPowerConsumption = mac.BatteryPowerConsumptions.Find(a => a.Channel == bi.Channel);
                }

                var tempCharge = new CuCharge(bi, batteryPowerConsumption);
                //panelControl2.Controls.Clear();
                //重写释放控件的方法,直接clear会导致句柄资源一直增加  20180422
                while (panelControl2.Controls.Count > 0)
                {
                    if (panelControl2.Controls[0] != null)
                    {
                        panelControl2.Controls[0].Dispose();
                    }
                }
                panelControl2.Controls.Add(tempCharge);
                tempCharge.Dock = DockStyle.Fill;

                //var node = treeViewSubstation.SelectedNode;
                //Dictionary<string, object> dic = new Dictionary<string, object>();
                //dic.Add("GetBatteryItem", ((Label)sender).Text);
                //dic.Add("SelNode", node);
                //_refStationBattery = new Thread(GetBatteryItemForSwicth);

                //_refStationBattery.Start(dic);
            }
            catch (Exception exc)
            {
                XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }