Ejemplo n.º 1
0
        void lvOutdoor_DragOver(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;

            if (UtilControl.CheckDragType_ListViewItem(e))
            {
                this.OnBeforeDrop(this.lvOutdoor, e);
            }

            string type = typeof(ListViewItem).ToString();

            if (e.Data.GetDataPresent(type, false))
            {
                e.Effect = DragDropEffects.Move;
            }
        }
Ejemplo n.º 2
0
        ///// 计算当前Control Group中不同模式下最大的室外机数量
        ///// <summary>
        ///// 计算当前Control Group中不同模式下最大的室外机数量,
        ///// Model模式:一个ONOFF返回4,一个CC返回16;
        ///// Bacnet模式:返回16
        ///// </summary>
        ///// <returns></returns>
        //public int GetMaxOutdoorQty_BeforeDrop(ControllerLayoutType type)
        //{
        //    if (type == ControllerLayoutType.MODBUS)
        //    {
        //        foreach (Control item in this.Controls)
        //        {
        //            if (item is ucDropController)
        //            {
        //                ucDropController ucController = item as ucDropController;
        //                if (ucController.IsActive)
        //                {
        //                    ControllerType controllerType = ucController.TypeInfo.Type;
        //                    if (controllerType == ControllerType.ONOFF)
        //                        return 4;
        //                }
        //            }
        //        }
        //    }
        //    return 16;
        //}

        ///// 计算当前Control Group中不同模式下最大的室外机数量
        ///// <summary>
        ///// 计算当前Control Group中不同模式下最大的室外机数量,
        ///// 只要看Bacnet模式:有CC则返回16,没有CC则返回ONOFF个数×4(小于等于16时)的值
        ///// </summary>
        ///// <param name="type"></param>
        ///// <returns></returns>
        //public int GetMaxOutdoorQty_AfterDrop(ControllerLayoutType type)
        //{
        //    if (type == ControllerLayoutType.BACNET)
        //    {
        //        int controllerQty_CC = GetControllerQty(ControllerType.CentralController);
        //        if (controllerQty_CC == 0)
        //        {
        //            int controllerQty = GetControllerQty(ControllerType.ONOFF);
        //            return controllerQty * 4;
        //        }
        //    }
        //    return GetMaxOutdoorQty_BeforeDrop(type);
        //}

        ///// 获取当前Control Group中不同模式下最大的控制器数量
        ///// <summary>
        ///// 获取当前Control Group中不同模式下最大的控制器数量
        ///// </summary>
        ///// <param name="type"></param>
        ///// <returns></returns>
        //public int GetMaxControllerQty(ControllerLayoutType type)
        //{
        //    if (type == ControllerLayoutType.MODBUS)
        //        return 1;
        //    return 16;
        //}


        /// Outdoor拖拽前可行性检查,不满足拖拽条件则弹出提示
        /// <summary>
        /// Outdoor拖拽前可行性检查,不满足拖拽条件则弹出提示
        /// </summary>
        /// <param name="sender">目标控件</param>
        /// <param name="e">源控件</param>
        /// <returns></returns>
        private bool CheckBeforeDropOutdoor(object sender, DragEventArgs e)
        {
            if (UtilControl.CheckDragType_ListViewItem(e))
            {
                ListView     lvTarget = (sender as ListView);                                   // 目标控件
                ListViewItem item     = (ListViewItem)e.Data.GetData(type_ListViewItem, false); // 源控件
                ListView     lvSrc    = item.ListView;

                // 如果源跟目标ListView同一个,则不可拖拽且不提示
                if (lvTarget == lvSrc && lvSrc.Parent is ucDropOutdoor)
                {
                    return(false);
                }

                //int currentOutdoorQty = GetOutdoorQty();
                //int maxOutdoorQty = GetMaxOutdoorQty_BeforeDrop(glProject.ControllerLayoutType);

                //// 拖拽前检查必须小于,不能等于允许的最大数量
                //if (currentOutdoorQty < maxOutdoorQty)
                //    return true;
                //else
                //    JCMsg.ShowWarningOK(Msg.CONTROLLER_OUTDOOR_QTY);

                //获取已经目标区域的各种设备数量
                int controllerQty = GetControllerQty();
                int outdoorQty    = GetOutdoorQty();
                int indoorQty     = GetIndoorQty();
                if (!item.Name.Contains("Heat Exchanger"))
                {
                    outdoorQty++;
                }

                //加上拖动的设备数量
                // outdoorQty++;
                if (item.Tag is Int32)
                {
                    indoorQty += Convert.ToInt32(item.Tag);
                }
                else if (item.Tag is Object[])
                {
                    Object[] values = item.Tag as Object[];
                    if (values != null && values.Length > 1 && values[1] is Int32)
                    {
                        indoorQty += Convert.ToInt32(values[1]);
                    }
                }
                //EU暂时忽略设备数及Hlink限制   add on 20180629 by axj
                if (_mainRegion == "EU_E" || _mainRegion == "EU_S" || _mainRegion == "EU_W")
                {
                    return(true);
                }

                //Ooutdoor Unit Quantity + Indoor Unit Quantity
                int unitQty = outdoorQty + indoorQty;

                //总设备数量
                int deviceQty = controllerQty + unitQty;  //TODO: 此处还需要加上remote controller的数量

                //检查设备数量是否符合H-Link的限制范围之内
                bool isHLinkII = !HasHLinkI();
                if (CheckHLinkLimiation(isHLinkII, indoorQty, outdoorQty, deviceQty) == false)
                {
                    return(false);
                }

                List <string> types = ucDropOutdoor1.GetProductTypesWith(item);

                //if (_mainRegion.StartsWith("EU"))   //对EU暂时取消限制
                //    return true;

                //检查设备数量是否符合各种controller的限制
                foreach (Control control in this.Controls)
                {
                    if (control is ucDropController)
                    {
                        ucDropController ucController = control as ucDropController;
                        if (ucController.TypeInfo != null)
                        {
                            ////检查产品类型是否匹配
                            //if (CheckProductType(types, ucController.TypeInfo.ProductType) == false)
                            //{
                            //    return false;
                            //}

                            //检查室内机、室外机和设备总数的限制
                            if (CheckSystemQtyLimitation(ucController.TypeInfo, indoorQty, outdoorQty, deviceQty) == false)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// 检验ucDropControlGroup中的Controller的拖拽
        /// <summary>
        /// 检验ucDropControlGroup中的Controller的拖拽
        /// </summary>
        /// <param name="sender">目标控件</param>
        /// <param name="e">源控件</param>
        /// <returns></returns>
        private bool CheckBeforeDropController(object sender, DragEventArgs e)
        {
            if (!UtilControl.CheckDragType_PictureBox(e))
            {
                return(false);
            }

            PictureBox pbTarget = sender as PictureBox;                        // 目标控件
            PictureBox pbSrc    = (PictureBox)e.Data.GetData(type_PictureBox); // 源控件


            //不能自己拖向自己
            if (pbTarget == pbSrc)
            {
                return(false);
            }

            ucDropController ucDropControllerSource = pbSrc.Parent is ucDropController ? (ucDropController)pbSrc.Parent : null;
            ucDropController ucDropControllerTarget = pbTarget.Parent is ucDropController ? (ucDropController)pbTarget.Parent : null;


            //不能目标不在controller group区域
            if (ucDropControllerTarget == null)
            {
                return(false);
            }

            CentralController controllerTypeSource;

            if (ucDropControllerSource == null)
            {
                controllerTypeSource = (pbSrc.Tag as CentralController);
            }
            else
            {
                controllerTypeSource = ucDropControllerSource.TypeInfo;
            }

            if (controllerTypeSource == null)
            {
                return(false);
            }

            //目标ucDropController控件已经含有controller
            if (ucDropControllerTarget.IsActive)
            {
                //如果不是同一种控制器,则不允许拖上去
                if (controllerTypeSource.Model != ucDropControllerTarget.TypeInfo.Model)
                {
                    return(false);
                }
            }
            //目标ucDropController控件是空白的
            else
            {
                // 若属于同一个ucDropControlGroup,则不可以拖拽
                if (pbSrc.Parent.Parent is ucDropControlGroup && pbSrc.Parent.Parent == this)
                {
                    return(false);
                }

                //如果已经存在此型号的controller则不允许添加
                if (this.HasControllerType(controllerTypeSource.Model))
                {
                    return(false);
                }
            }

            //拖动的controller的数量
            int addNumber = 1;

            if (ucDropControllerSource != null && ucDropControllerSource.Controller != null)
            {
                addNumber = ucDropControllerSource.Controller.Quantity;
            }
            ListViewItem item = (ListViewItem)e.Data.GetData(type_ListViewItem, false);

            //继续检查
            return(CheckBeforeAddController(controllerTypeSource, addNumber));
        }