/// <summary>
 /// 从订单页面打开时,要调用这个函数
 /// </summary>
 /// <param name="imageModelList"></param>
 /// <returns></returns>
 public static List<ImageEntity> getImageEntityFromDataBase(List<ImageModel> imageModelList)
 {
     List<ImageEntity> imageList = new List<ImageEntity>();
     //int height = 0;
     //int width = 0;
     for (int i = 0; i < imageModelList.Count;i++ )
     {
         ImageEntity imageEntity = new ImageEntity();
         ImageModel imageModel=imageModelList.ElementAt(i);
         imageEntity.coolingType = imageModel.coolingType;
         imageEntity.firstDistance = imageModel.FirstDance;
         imageEntity.isSelected = imageModel.IsSelected;
         imageEntity.moduleTag = imageModel.ModuleTag;
         imageEntity.Name = imageModel.Name;
         imageEntity.orderId = imageModel.OrderId;
         imageEntity.parentName = imageModel.ParentName;
         //if (imageModel.Name.Equals("HRA"))
         //{
         //    height = Convert.ToInt32((imageModel.Height - 2) * FrontPhotoService.factor + 2);
         //    width = Convert.ToInt32(imageModel.Width*FrontPhotoService.factor);
         //}
         //else
         //{
         //    height =Convert.ToInt32(imageModel.Height*FrontPhotoService.factor);
         //    width = Convert.ToInt32(imageModel.Width * FrontPhotoService.factor);
         //}
         imageEntity.Rect = new System.Drawing.Rectangle(imageModel.X, imageModel.Y, imageModel.Width, imageModel.Height);
         imageEntity.secondDistance = imageModel.SecondDance;
         imageEntity.Text = imageModel.Text;
         imageEntity.Type = imageModel.Type;
         imageEntity.Url = imageModel.Url;
         imageEntity.Guid = imageModel.Guid;
         imageEntity.thirdDistance = imageModel.ThirdDistance;
         imageEntity.topViewFirstDistance = imageModel.TopViewFirstDistance;
         imageEntity.topViewSecondDistance = imageModel.TopViewSecondDistance;
         imageEntity.imageWidth =Convert.ToInt32(imageModel.ImageWidth);
         imageList.Add(imageEntity);
     }
     imageList = FrontPhotoService.zoomInImangeEntity(imageList,FrontPhotoService.factor);
     return imageList;
 }
示例#2
0
        void CustomForm_MouseDown(object sender, MouseEventArgs e)
        {
            //MessageBox.Show("test");
            // Determine the initial rectangle coordinates...
            downPoint = new Point(e.X, e.Y);

            //如果当前的点击在图片区域内,则形成一个矩形框,此处作为判断并列的图块的判断
            if (rowImageEntities.Count > 0)
            {
                foreach (var imageEntity in rowImageEntities)
                {
                    if (imageEntity.HitTest(downPoint))
                    {
                        //设置矩形框存在,并且将矩形框的rect设置为当前选中的图块的rect
                        //并保存矩形框的起始点.一旦有图块被选中,则终止循环判断
                        //设置选中的图块为该图块
                        rectExist = true;
                        //selectedRectangle = imageEntity.Rect;
                        //2012-9-4修改消除HRA花矩形框影响
                        if (imageEntity.Name.Equals("virtualHRA"))
                        {
                            foreach(var hraEntity in rowImageEntities)
                            {
                                if (hraEntity.Name.Equals(RightImageRangeType.imageRangeType.ElementAt(0).ToString()))
                                {
                                    selectedRectangle = hraEntity.Rect;
                                    selectedImageEntity = hraEntity;
                                    //单击按下选中为画网格做准
                                    //2012-9-4
                                    selectedImageEntity.isSelected = true;
                                    foreach (var cancelSelected in rowImageEntities)
                                    {
                                        if (cancelSelected.Name != selectedImageEntity.Name || cancelSelected.Rect != selectedImageEntity.Rect)
                                        {
                                            cancelSelected.isSelected = false;
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            selectedRectangle = imageEntity.Rect;
                            selectedImageEntity = imageEntity;
                            //单击按下选中为画网格做准
                            //2012-9-4
                            selectedImageEntity.isSelected = true;
                            foreach(var cancelSelected in rowImageEntities){

                                if (cancelSelected.Name != selectedImageEntity.Name || cancelSelected.Rect != selectedImageEntity.Rect)
                                {
                                    cancelSelected.isSelected = false;
                                }
                            }
                        }

                        beginPoint = new Point(selectedRectangle.X, selectedRectangle.Y);
                        //确认选中
                        isHitted = true;
                        this.Invalidate();
                        return;
                    }
                }
            }

            //如果在重叠图块内
            if (overlapImageEntities!=null&&overlapImageEntities.Count>0)
            {
                var lastImageEntity = overlapImageEntities.Last();
                if (lastImageEntity.HitTest(downPoint))
                {
                    rectExist = true;
                    selectedRectangle = lastImageEntity.Rect;
                    selectedImageEntity = lastImageEntity;
                    beginPoint = new Point(selectedRectangle.X, selectedRectangle.Y);
                    isHitted = true;
                   //this.Invalidate();
                    return;
                }
            }
            isHitted = false;

            this.Invalidate();
        }
示例#3
0
 void panel3_OnEntityDBClick(ImageEntity imageEntity)
 {
     FrontPhotoService.recoveryLeftOrRightParamerter();
     imageBoxList = FrontPhotoImageModelService.getTagModuleImageList(imageBoxList);
     new ModuleDetail(FrontPhotoImageModelService.getDoubleClickImageModelList(imageBoxList)).ShowDialog();
 }
示例#4
0
        void panel3_OnEntityClick(ImageEntity imageEntity)
        {
            isNonSelected = false;
            for (int i = 0; i < imageBoxList.Count; i++)
            {
                if (imageEntity.Rect.X == imageBoxList.ElementAt(i).Rect.X && imageEntity.Rect.Y == imageBoxList.ElementAt(i).Rect.Y && imageEntity.Name == imageBoxList.ElementAt(i).Name)
                {
                    imageBoxList.ElementAt(i).isSelected = true;
                    //设置replace被选中
                        tabControl1.SelectedIndex = 1;

                        string imageName = imageBoxList.ElementAt(i).Name == "virtualHRA" ? "HR Wheel": imageBoxList.ElementAt(i).parentName;

                        int tabIndex = FrontPhotoService.tabControlImageIndex[imageName];
                        tab_Replace.SelectedIndex = tabIndex;
                        reFreshEdByReplace(tabIndex);
                        isAddOrReplace = true;
                    //生成图片选中文字信息,在中间显示
                        FrontPhotoService.selectedModule = imageBoxList.ElementAt(i).parentName;
                        FrontPhotoService.imageSerialNo = "" + imageBoxList.ElementAt(i).Name
                            + "-" + imageBoxList.ElementAt(i).moduleTag
                            + "-P" + "-A" + i + "-000" + i + "-000" + i + "-0" + "-0";
                        centerTopInfoList = FrontPhotoService.getMiddleEachInformation(FrontPhotoService.selectedModule, FrontPhotoService.imageSerialNo);

                   //设置选中图片的位置
                    if (FrontPhotoService.rightAlignment || FrontPhotoService.leftAlignment)
                    {
                        if (imageBoxList.ElementAt(i).Rect.Y < FrontPhotoService.leftStartY)
                        {
                            FrontPhotoService.upSelectedElement = i;
                        }
                        else
                        {
                            FrontPhotoService.downSelectedElement = i;
                        }
                    }
                }
                else
                {
                    imageBoxList.ElementAt(i).isSelected = false;
                }
            }
            if (FrontPhotoService.upSelectedElement > -1 && FrontPhotoService.downSelectedElement > -1)
            {
                imageBoxList = FrontPhotoService.calculateAlignmentLeftOrRight(imageBoxList,FrontPhotoService.downSelectedElement, FrontPhotoService.upSelectedElement);
                panel3.TopInfo = centerTopInfoList;
                panel3.RowImageEntities = imageBoxList;
                panel3.Invalidate();
            }
            else
            {
                panel3.TopInfo = centerTopInfoList;
                panel3.RowImageEntities = imageBoxList;
                panel3.Invalidate();
            }

            isNonSelected = true;
        }
示例#5
0
        /// <summary>
        /// 生成浏览dxf代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            //DxfDocument dxf = new DxfDocument();
            DxfModel dxf = new DxfModel(DxfVersion.Dxf15);
            //获取dxf图纸左上角图纸说明信息
            List<string> dxfImageInfoList = FrontPhotoService.translateImageInfo(FrontPhotoService.productionDescription, imageBoxList);
            //缩放到真实比例
            List<ImageEntity> dxfPaintImageBoxList = new List<ImageEntity>();
            for (int i = 0; i < imageBoxList.Count;i++ )
            {
                ImageEntity dxfPaintEntity = new ImageEntity();
                dxfPaintEntity.Name = imageBoxList.ElementAt(i).Name;
                dxfPaintEntity.Rect = imageBoxList.ElementAt(i).Rect;
                dxfPaintEntity.imageWidth = imageBoxList.ElementAt(i).imageWidth;
                dxfPaintEntity.Type = imageBoxList.ElementAt(i).Type;
                dxfPaintEntity.Url = imageBoxList.ElementAt(i).Url;
                dxfPaintEntity.Text = imageBoxList.ElementAt(i).Text;
                dxfPaintEntity.firstDistance = imageBoxList.ElementAt(i).firstDistance;
                dxfPaintEntity.secondDistance = imageBoxList.ElementAt(i).secondDistance;
                dxfPaintEntity.coolingType = imageBoxList.ElementAt(i).coolingType;
                dxfPaintEntity.thirdDistance = imageBoxList.ElementAt(i).thirdDistance;
                dxfPaintEntity.topViewFirstDistance = imageBoxList.ElementAt(i).topViewFirstDistance;
                dxfPaintEntity.topViewSecondDistance = imageBoxList.ElementAt(i).topViewSecondDistance;
                dxfPaintImageBoxList.Add(dxfPaintEntity);
            }
                dxfPaintImageBoxList = FrontPhotoService.zoomOutImageEntity(dxfPaintImageBoxList, 1 / FrontPhotoService.factor);
            List<PictureBoxInfo> dxfReflectPictureNameList = new List<PictureBoxInfo>();
            for (int i = 0, len = dxfPaintImageBoxList.Count; i < len; i++)
            {
                ImageEntity imageEntity = dxfPaintImageBoxList.ElementAt(i);
               // if(imageEntity.Name!="virtualHRA"){
                     PictureBoxInfo pbi = new PictureBoxInfo();
                //pbi.location = new Location(tempDxfRelectPictureBox.Location.X,tempDxfRelectPictureBox.Location.Y,0);
                     pbi.DLocation = new DLocation(imageEntity.Rect.X, imageEntity.Rect.Y, 0);
                     pbi.height = imageEntity.Rect.Height;
                    //相当于设备的长度
                     pbi.width = imageEntity.Rect.Width;
                     pbi.topViewHeight = imageEntity.imageWidth;
                     pbi.name = imageEntity.Name;
                     pbi.text = TextSplitService.textSplit(imageEntity.Text);
                     pbi.firstDistance = imageEntity.firstDistance;
                     pbi.secondDistance = imageEntity.secondDistance;
                     pbi.coolingType = imageEntity.coolingType;
                     pbi.thirdDistance = imageEntity.thirdDistance;
                     pbi.topViewFirstDistance = imageEntity.topViewFirstDistance;
                     pbi.topViewSecondDistance = imageEntity.topViewSecondDistance;
                     dxfReflectPictureNameList.Add(pbi);
               // }
            }

            //dxfReflectPictureNameList = FrontPhotoService.getRanglePictureInfoList(dxfReflectPictureNameList);

            DataCenter dataCenter = new DataCenter();
            dataCenter.SectionEntity = new SectionEntity("40", "60");
            dataCenter.OrderEntity = new OrderEntity("jobname", "unittag");
            //图纸左上角说明信息
            dataCenter.Configurations = dxfImageInfoList;

            dataCenter.detailMechineConfigure=new DetailMechineConfigure(dxfReflectPictureNameList,
                 new string[] { "hello", "world", "helloworld" }, 44.0f, 18, 1.0f, 1.56f, 2.0f, 2.0f);
            dataCenter.topViewConfigure = new TopViewConfigure(dxfReflectPictureNameList, dxf, null, 50.0f, 18.0f, 2.0f, 2.86f, 2.0f, 2.0f);

            //float totalWidth = TotalWidthAndHeight.getWidth(dxfReflectPictureNameList);
            //获得下层链表
            List<ImageEntity> tempDownList = FrontPhotoService.getDownList(imageBoxList);
            double totalWidth = TotalWidthAndHeight.getWidth(tempDownList);
            //double totalWidth = TotalWidthAndHeight.getWidth(dxfReflectPictureNameList);
            if (AssembleDetailMechine.isTwoLayers(dxfReflectPictureNameList)!=-1)
            {
                //float[] upOrDownHeightOrViewHieght = new float[3];
                double[] upOrDownHeightOrViewHieght = new double[3];
                upOrDownHeightOrViewHieght = TotalWidthAndHeight.getEachLayerHight(dxfReflectPictureNameList);
                dataCenter.BoxEntity = new BoxEntity { DownHeight = upOrDownHeightOrViewHieght[0], UpHeight = upOrDownHeightOrViewHieght[1], Width = totalWidth, TopViewHeight = upOrDownHeightOrViewHieght[2], IsLeft =FrontPhotoService.mirrorDirection.Equals("mirrorRight")?true:false };
            }
            else
            {
                //float[] upOrDownHeightOrViewHieght = new float[3];
                double[] upOrDownHeightOrViewHieght = new double[3];
                upOrDownHeightOrViewHieght = TotalWidthAndHeight.getEachLayerHight(dxfReflectPictureNameList);
                dataCenter.BoxEntity = new BoxEntity { DownHeight = upOrDownHeightOrViewHieght[0], UpHeight = 0, Width = totalWidth, TopViewHeight = upOrDownHeightOrViewHieght[2], IsLeft = FrontPhotoService.mirrorDirection.Equals("mirrorRight") ? true : false };
            }

            OuterBox outerBox = new OuterBox();
            outerBox.dataCenter = dataCenter;
            //outerBox.Draw(dxf, new Location(500, 500), 306, 188, dxfReflectPictureNameList,5);
            outerBox.Draw(dxf, new DLocation(FrontPhotoService.leftStartX, FrontPhotoService.leftStartY), 306, 188, dxfReflectPictureNameList, 5);

            //dxf.Save("AutoCad2007.dxf", DxfVersion.AutoCad2007);
            //dxf.Save("AutoCad2004.dxf", DxfVersion.AutoCad2004);
            //dxf.Save("AutoCad2000.dxf", DxfVersion.AutoCad2000);
            //dxf.Save("AutoCad12.dxf", DxfVersion.AutoCad12);

            DxfWriter.Write("DxfWriteExample-R15-ascii.dxf", dxf, false);
            DxfWriter.Write("DxfWriteExample-R15-bin.dxf", dxf, true);

            DxfViewer dv = new DxfViewer();
            dv.setDxfFile("DxfWriteExample-R15-ascii.dxf");
            dv.Show();

            //MessageBox.Show("图纸生成成功!");
        }
示例#6
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            FrontPhotoService.recoveryLeftOrRightParamerter();

            if (imageBoxList.ElementAt(0).Name.Equals("virtualHRA") && imageBoxList.Count == 2)
            {
                MessageBox.Show("Cann't delete the last one!");
                return;
            }
               else if (imageBoxList.Count == 1)
            {
                MessageBox.Show("Cann't delete the last one!");
                return;
            }

            ImageEntity deleteImageEntity = new ImageEntity();
            for (int i = 0; i < imageBoxList.Count; i++)
            {

                if (imageBoxList.ElementAt(i).isSelected)
                {
                    //有跳跃的bub,解决
                    if (imageBoxList.ElementAt(i).Name.Equals("virtualHRA"))
                    {
                        imageBoxList.ElementAt(i).isSelected = false;
                        tabControl1.SelectedIndex = 0;
                        return;
                    }
                    deleteImageEntity = imageBoxList.ElementAt(i);
                    tabControl1.SelectedIndex = 0;
                }
            }
            imageBoxList=FrontPhotoService.deleteImageEntityPosition(imageBoxList, deleteImageEntity, "mirrorRight");

            //删除上层元素
            for (int i = 0; i < leftTopImageBoxList.Count;i++ )
            {
                if(leftTopImageBoxList.ElementAt(i).isSelected){
                    leftTopImageBoxList.RemoveAt(i);
                    tabControl1.SelectedIndex = 0;
                }
            }

               // 自动居中计算
            FrontPhotoService.setCenter(imageBoxList,panel3.Width,FrontPhotoService.mirrorDirection);
            imageBoxList = FrontPhotoService.calculatePositionByCoolingType(imageBoxList, FrontPhotoService.mirrorDirection);
            //画右边信息
            downImageEnityList = FrontPhotoService.getDownList(imageBoxList);
            FrontPhotoService.initRightTopInformation(FrontPhotoImageModelService.operatePhotoNeedData, downImageEnityList, imageBoxList, coolingType);
            rightTopInfoList = FrontPhotoService.getTopRightEquipmentInformation(FrontPhotoService.productionDescription, FrontPhotoService.downTotalLength, FrontPhotoService.totalHeight, FrontPhotoService.imageWidth);

            panel3.RowImageEntities = imageBoxList;
            panel3.TopRightInfo = rightTopInfoList;
            panel3.Invalidate();
        }
示例#7
0
        private void panel3_OnEntityMove(ImageEntity srcEntity, ImageEntity destEntity)
        {
            if (srcEntity.Type == "row")
            {
                //removeListImageEntity(imageBoxList, srcEntity);
                if (FrontPhotoService.mirrorDirection.Equals("mirrorRight"))
                {
                    //居中
                  //  imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);

                    //FrontPhotoService.leftStartX = panel3.Width - 400;
                    imageBoxList = FrontPhotoService.calculateImageEntityPosition(imageBoxList, srcEntity, destEntity, "mirrorRight");

                    //判断是否自动缩小,超出了panel一定的边界
                    if (FrontPhotoService.isZoomOut(imageBoxList, panel3.Width))
                    {
                        imageBoxList = FrontPhotoService.zoomOutImageEntity(imageBoxList, zoomOutFactor);
                        FrontPhotoService.factor *= zoomOutFactor;

                        //缩小后居中
                        imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                    }

                    ////居中
                    imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                    if (imageBoxList.ElementAt(0).Rect.X < panel3.Width / 8)
                    {
                       // imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                        imageBoxList = FrontPhotoService.calculatePositionByCoolingType(imageBoxList, FrontPhotoService.mirrorDirection);
                    }

                }
                else
                {
                    //居中
                  //  imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);

                   // FrontPhotoService.leftStartX = 200;

                    imageBoxList = FrontPhotoService.calculateImageEntityPosition(imageBoxList, srcEntity, destEntity, "mirrorLeft");

                    //判断是否自动缩小,超出了panel一定的边界
                    if (FrontPhotoService.isZoomOut(imageBoxList, panel3.Width))
                    {
                        imageBoxList = FrontPhotoService.zoomOutImageEntity(imageBoxList, zoomOutFactor);
                        FrontPhotoService.factor *= zoomOutFactor;

                        //缩小后居中
                        imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                    }

                    ////居中
                    imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                    if (imageBoxList.ElementAt(0).Rect.X < panel3.Width / 8)
                    {

                        imageBoxList = FrontPhotoService.calculatePositionByCoolingType(imageBoxList, FrontPhotoService.mirrorDirection);
                    }

                }
                //画右边信息
                downImageEnityList = FrontPhotoService.getDownList(imageBoxList);
                FrontPhotoService.initRightTopInformation(FrontPhotoImageModelService.operatePhotoNeedData, downImageEnityList, imageBoxList, coolingType);
                rightTopInfoList = FrontPhotoService.getTopRightEquipmentInformation(FrontPhotoService.productionDescription, FrontPhotoService.downTotalLength, FrontPhotoService.totalHeight, FrontPhotoService.imageWidth);
                //2012-9-4
                //陈志东
                //改变imageBoxList的编号,重新排序
                imageBoxList = FrontPhotoImageModelService.getTagModuleImageList(imageBoxList);
                panel3.RowImageEntities = imageBoxList;
                panel3.TopRightInfo = rightTopInfoList;
            }
            else if (srcEntity.Type == "over")
            {
                if (srcEntity.Rect.X != destEntity.Rect.X || srcEntity.Rect.Y != destEntity.Rect.Y)
                {
                    if (FrontPhotoService.mirrorDirection.Equals("mirrorRight"))
                    {

                      //  FrontPhotoService.leftStartX = panel3.Width - 400;

                        leftTopImageBoxList = FrontPhotoService.removeListImageEntity(leftTopImageBoxList, srcEntity);
                        imageBoxList = FrontPhotoService.calculateImageEntityPosition(imageBoxList, srcEntity, destEntity, "mirrorRight");
                       // 判断是否自动缩小,超出了panel一定的边界
                        if (FrontPhotoService.isZoomOut(imageBoxList, panel3.Width))
                        {
                            imageBoxList = FrontPhotoService.zoomOutImageEntity(imageBoxList, zoomOutFactor);
                            FrontPhotoService.factor *= zoomOutFactor;

                            //缩小后居中
                            imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                        }

                        ////居中
                        if (imageBoxList.ElementAt(0).Rect.X < panel3.Width / 8)
                        {
                            imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                            imageBoxList = FrontPhotoService.calculatePositionByCoolingType(imageBoxList, FrontPhotoService.mirrorDirection);
                        }
                    }
                    else
                    {
                        //FrontPhotoService.leftStartX = 200;
                        leftTopImageBoxList = FrontPhotoService.removeListImageEntity(leftTopImageBoxList, srcEntity);
                        imageBoxList = FrontPhotoService.calculateImageEntityPosition(imageBoxList, srcEntity, destEntity, "mirrorLeft");

                        //判断是否自动缩小,超出了panel一定的边界
                        if (FrontPhotoService.isZoomOut(imageBoxList, panel3.Width))
                        {
                            imageBoxList = FrontPhotoService.zoomOutImageEntity(imageBoxList, zoomOutFactor);
                            FrontPhotoService.factor *= zoomOutFactor;
                            //缩小后居中
                            imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                        }

                        ////居中
                        if (imageBoxList.ElementAt(0).Rect.X < panel3.Width / 8)
                        {
                            imageBoxList = FrontPhotoService.setCenter(imageBoxList, panel3.Width, FrontPhotoService.mirrorDirection);
                            imageBoxList = FrontPhotoService.calculatePositionByCoolingType(imageBoxList, FrontPhotoService.mirrorDirection);
                        }
                    }

                    //画右边信息
                    downImageEnityList = FrontPhotoService.getDownList(imageBoxList);
                    FrontPhotoService.initRightTopInformation(FrontPhotoImageModelService.operatePhotoNeedData, downImageEnityList, imageBoxList, coolingType);
                    rightTopInfoList = FrontPhotoService.getTopRightEquipmentInformation(FrontPhotoService.productionDescription, FrontPhotoService.downTotalLength, FrontPhotoService.totalHeight, FrontPhotoService.imageWidth);
                    //对每个图块的标签重新命名(101,102)
                    //2012-9-4
                    //陈志东
                    imageBoxList = FrontPhotoImageModelService.getTagModuleImageList(imageBoxList);
                    panel3.RowImageEntities = imageBoxList;
                    panel3.TopRightInfo = rightTopInfoList;
                }
            }

            //2012-9-4
            //解决因为按下选中后tabControl切换的问题
            //下面就是单击的内容
            isNonSelected = false;
            for (int i = 0; i < imageBoxList.Count; i++)
            {
                if (destEntity.Rect.X == imageBoxList.ElementAt(i).Rect.X && destEntity.Rect.Y == imageBoxList.ElementAt(i).Rect.Y && destEntity.Name == imageBoxList.ElementAt(i).Name)
                {
                    imageBoxList.ElementAt(i).isSelected = true;
                    //设置replace被选中
                    tabControl1.SelectedIndex = 1;

                    string imageName = imageBoxList.ElementAt(i).Name == "virtualHRA" ? "HR Wheel" : imageBoxList.ElementAt(i).parentName;

                    int tabIndex = FrontPhotoService.tabControlImageIndex[imageName];
                    tab_Replace.SelectedIndex = tabIndex;
                    reFreshEdByReplace(tabIndex);
                    isAddOrReplace = true;
                    //生成图片选中文字信息,在中间显示
                    FrontPhotoService.selectedModule = imageBoxList.ElementAt(i).parentName;
                    FrontPhotoService.imageSerialNo = "" + imageBoxList.ElementAt(i).Name
                        + "-" + imageBoxList.ElementAt(i).moduleTag
                        + "-P" + "-A" + i + "-000" + i + "-000" + i + "-0" + "-0";
                    centerTopInfoList = FrontPhotoService.getMiddleEachInformation(FrontPhotoService.selectedModule, FrontPhotoService.imageSerialNo);

                    //设置选中图片的位置
                    if (FrontPhotoService.rightAlignment || FrontPhotoService.leftAlignment)
                    {
                        if (imageBoxList.ElementAt(i).Rect.Y < FrontPhotoService.leftStartY)
                        {
                            FrontPhotoService.upSelectedElement = i;
                        }
                        else
                        {
                            FrontPhotoService.downSelectedElement = i;
                        }
                    }
                }
                else
                {
                    imageBoxList.ElementAt(i).isSelected = false;
                }
            }
            if (FrontPhotoService.upSelectedElement > -1 && FrontPhotoService.downSelectedElement > -1)
            {
                imageBoxList = FrontPhotoService.calculateAlignmentLeftOrRight(imageBoxList, FrontPhotoService.downSelectedElement, FrontPhotoService.upSelectedElement);
                panel3.TopInfo = centerTopInfoList;
                panel3.RowImageEntities = imageBoxList;
                panel3.Invalidate();
            }
            else
            {
                panel3.TopInfo = centerTopInfoList;
                panel3.RowImageEntities = imageBoxList;
                panel3.Invalidate();
            }

            isNonSelected = true;
        }
示例#8
0
        //根据名字和coolingType获得 imageEntity
        public static ImageEntity getImageEntityByCoolingType(string name,int coolingType,ImageEntity imageEntityChanged)
        {
            int startXPosition = imageEntityChanged.Rect.X;
            int startYPosition=imageEntityChanged.Rect.Y;
            ImageBlock imageBlock;

            ImageEntity imageEntity = new ImageEntity();
            imageEntity.Name = name;
            imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntity.Name, coolingType);
            int ftaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
            int ftaHight = Convert.ToInt32(imageBlock.ImageHeight * factor);
            imageEntity.Rect = new Rectangle(startXPosition, startYPosition, ftaWidth, ftaHight);
            imageEntity.Url = ImageBoxService.getImageUrl(imageEntity.Name);
            imageEntity.Type = "row";
            imageEntity.Text = imageBlock.Text;
            imageEntity.firstDistance = imageBlock.FirstDistance;
            imageEntity.secondDistance = imageBlock.SecondDistance;
            imageEntity.coolingType = coolingType;
            imageEntity.isSelected = false;
            imageEntity.moduleTag =imageEntityChanged.moduleTag;
            imageEntity.parentName = imageBlock.ParentName;
            imageEntity.Guid = Guid.NewGuid().ToString("N");
            imageEntity.orderId = FrontPhotoImageModelService.orderId;
            imageEntity.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
            imageEntity.thirdDistance = imageBlock.ThirdDistance;
            imageEntity.topViewFirstDistance = imageBlock.TopViewFirstDistance;
            imageEntity.topViewSecondDistance = imageBlock.TopViewSecondDistance;

            return imageEntity;
        }
示例#9
0
 //比较器
 private static int comparison(ImageEntity imageEntity1, ImageEntity imageEntity2)
 {
     return imageEntity1.Rect.X.CompareTo(imageEntity2.Rect.X);
 }
示例#10
0
 //替换左上角元素的算法
 public static List<ImageEntity> replaceLeftTopCurrent(List<ImageEntity> leftTopImageList,ImageEntity imageEntity)
 {
     for (int i = leftTopImageList.Count-1; i >=0;i-- )
     {
         if (leftTopImageList.ElementAt(i).isSelected)
         {
             imageEntity.Rect = new Rectangle(leftTopImageList.ElementAt(i).Rect.X, leftTopImageList.ElementAt(i).Rect.Y, imageEntity.Rect.Width, imageEntity.Rect.Height);
             imageEntity.Type = leftTopImageList.ElementAt(i).Type;
             leftTopImageList[i] = imageEntity;
             break;
         }
     }
     return leftTopImageList;
 }
示例#11
0
 //替换当前选中的算法(imageBoxList)
 public static List<ImageEntity> replaceCurrent(List<ImageEntity> imageList,ImageEntity imageEntity,string mirrorDirection)
 {
     for (int i = 0; i < imageList.Count;i++ )
     {
         if (imageList.ElementAt(i).isSelected)
         {
             imageEntity.Rect =new Rectangle(imageList.ElementAt(i).Rect.X,imageList.ElementAt(i).Rect.Y,imageEntity.Rect.Width,imageEntity.Rect.Height);
             imageEntity.Type = imageList.ElementAt(i).Type;
             imageList[i] = imageEntity;
             break;
         }
     }
     imageList=calculateImageEntityPosition(imageList, imageEntity, imageEntity, mirrorDirection);
     return imageList;
 }
示例#12
0
 public static List<ImageEntity> removeListImageEntity(List<ImageEntity> srcList, ImageEntity srcEntity)
 {
     for (int i = 0; i < srcList.Count; i++)
     {
         ImageEntity tempImageEntity = srcList.ElementAt(i);
         if (tempImageEntity.Rect.X == srcEntity.Rect.X && tempImageEntity.Rect.Y == srcEntity.Rect.Y && tempImageEntity.Rect.Width == srcEntity.Rect.Width && tempImageEntity.Rect.Height == srcEntity.Rect.Height)
         {
             if (srcList.Count > 0)
                 srcList.RemoveAt(i);
         }
     }
     return srcList;
 }
示例#13
0
        //删除元素是否为第一个
        public static bool isDeleteUpFirstElement(List<ImageEntity> imageList,ImageEntity deleteImageElement)
        {
            List<ImageEntity> downList = new List<ImageEntity>();
            List<ImageEntity> upList = new List<ImageEntity>();
            for (int i = 0; i < imageList.Count; i++)
            {
                ImageBlock imageBlock = ImageBlockBLL.getImageBlocksByNames(imageList.ElementAt(i).Name, imageList.ElementAt(i).coolingType);
                if (i == 0)
                {
                    downList.Add(imageList.ElementAt(0));

                }
                else
                {
                    ImageEntity firstDownElement = imageList.ElementAt(0);
                    if ((firstDownElement.Rect.Y == imageList.ElementAt(i).Rect.Y || Math.Abs(firstDownElement.Rect.Y - imageList.ElementAt(i).Rect.Y) < 0.6 * imageList.ElementAt(i).Rect.Height || firstDownElement.Rect.Y - imageList.ElementAt(i).Rect.Y < 0 || imageList.ElementAt(i).Name == "virtualHRA" || FrontPhotoConstraintService.onlyExistDownLayerElement.Contains(imageList.ElementAt(i).Name)) && imageList.ElementAt(i).Name != "HRA")
                    {
                        downList.Add(imageList.ElementAt(i));
                    }
                    else
                    {
                        upList.Add(imageList.ElementAt(i));
                    }
                }
            }
            if(upList.Count>0){
                if (deleteImageElement.Rect.X == upList.ElementAt(0).Rect.X && deleteImageElement.Rect.Y == upList.ElementAt(0).Rect.Y && deleteImageElement.Name == upList.ElementAt(0).Name)
                {
                    return true;
                }
            }
            return false;
        }
示例#14
0
        public static List<ImageEntity> initSingleLayerOPeratorPhoto(List<ImageEntity> imageBoxList,int coolingType=5,string startUnitAs="Basic Air Handler")
        {
            int startXPosition = 200;
            int startYPosition = 350;
            if (startUnitAs.Equals("Basic Air Handler"))
            {
                ImageBlock imageBlock;

                ImageEntity imageEntityFTA = new ImageEntity();
                imageEntityFTA.Name = "FTA";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityFTA.Name, coolingType);
                int ftaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int ftaHight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityFTA.Rect = new Rectangle(startXPosition, startYPosition, ftaWidth, ftaHight);
                imageEntityFTA.Url = ImageBoxService.getImageUrl(imageEntityFTA.Name);
                imageEntityFTA.Type = "row";
                imageEntityFTA.Text = imageBlock.Text;
                imageEntityFTA.firstDistance = imageBlock.FirstDistance;
                imageEntityFTA.secondDistance = imageBlock.SecondDistance;
                imageEntityFTA.coolingType = coolingType;
                imageEntityFTA.isSelected = false;
                imageEntityFTA.moduleTag = "101-" + imageBlock.ParentName;
                imageEntityFTA.parentName = imageBlock.ParentName;
                imageEntityFTA.Guid = Guid.NewGuid().ToString("N");
                imageEntityFTA.orderId = FrontPhotoImageModelService.orderId;
                imageEntityFTA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityFTA.thirdDistance = imageBlock.ThirdDistance;
                imageEntityFTA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityFTA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityCLF = new ImageEntity();

                imageEntityCLF.Name = "CLF";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityCLF.Name, coolingType);
                int clfWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int clfHeight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityCLF.Url = ImageBoxService.getImageUrl(imageEntityCLF.Name);
                imageEntityCLF.Rect = new Rectangle(imageEntityFTA.Rect.X + imageEntityFTA.Rect.Width + 1, imageEntityFTA.Rect.Y, clfWidth, clfHeight);
                imageEntityCLF.Type = "row";
                imageEntityCLF.Text = imageBlock.Text;
                imageEntityCLF.firstDistance = imageBlock.FirstDistance;
                imageEntityCLF.secondDistance = imageBlock.SecondDistance;
                imageEntityCLF.coolingType = coolingType;
                imageEntityCLF.isSelected = false;
                imageEntityCLF.moduleTag = "102-" + imageBlock.ParentName;
                imageEntityCLF.parentName = imageBlock.ParentName;
                imageEntityCLF.Guid = Guid.NewGuid().ToString("N");
                imageEntityCLF.orderId = FrontPhotoImageModelService.orderId;
                imageEntityCLF.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityCLF.thirdDistance = imageBlock.ThirdDistance;
                imageEntityCLF.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityCLF.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntitySFA = new ImageEntity();
                if (coolingType <= 14)
                {
                    imageEntitySFA.Name = "SFA";
                }
                else
                {
                    imageEntitySFA.Name = "SDB";
                }
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntitySFA.Name, coolingType);
                int sfaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int sfaHeight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntitySFA.Url = ImageBoxService.getImageUrl(imageEntitySFA.Name);
                imageEntitySFA.Rect = new Rectangle(imageEntityCLF.Rect.X + imageEntityCLF.Rect.Width + 1, imageEntityCLF.Rect.Y, sfaWidth, sfaHeight);
                imageEntitySFA.Type = "row";
                imageEntitySFA.Text = imageBlock.Text;
                imageEntitySFA.firstDistance = imageBlock.FirstDistance;
                imageEntitySFA.secondDistance = imageBlock.SecondDistance;
                imageEntitySFA.coolingType = coolingType;
                imageEntitySFA.isSelected = false;
                imageEntitySFA.moduleTag = "103-" + imageBlock.ParentName;
                imageEntitySFA.parentName = imageBlock.ParentName;
                imageEntitySFA.Guid = Guid.NewGuid().ToString("N");
                imageEntitySFA.orderId = FrontPhotoImageModelService.orderId;
                imageEntitySFA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntitySFA.thirdDistance = imageBlock.ThirdDistance;
                imageEntitySFA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntitySFA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                imageBoxList.Add(imageEntityFTA);
                imageBoxList.Add(imageEntityCLF);
                imageBoxList.Add(imageEntitySFA);
            }
            else
            {
                ImageBlock imageBlock;

                ImageEntity imageEntityFTF = new ImageEntity();
                imageEntityFTF.Name = "FTF";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityFTF.Name, coolingType);
                int ftfWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int ftfHight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityFTF.Rect = new Rectangle(startXPosition, startYPosition, ftfWidth, ftfHight);
                imageEntityFTF.Url = ImageBoxService.getImageUrl(imageEntityFTF.Name);
                imageEntityFTF.Type = "row";
                imageEntityFTF.Text = imageBlock.Text;
                imageEntityFTF.firstDistance = imageBlock.FirstDistance;
                imageEntityFTF.secondDistance = imageBlock.SecondDistance;
                imageEntityFTF.coolingType = coolingType;
                imageEntityFTF.isSelected = false;
                imageEntityFTF.moduleTag = "101-" + imageBlock.ParentName;
                imageEntityFTF.parentName = imageBlock.ParentName;
                imageEntityFTF.Guid = Guid.NewGuid().ToString("N");
                imageEntityFTF.orderId = FrontPhotoImageModelService.orderId;
                imageEntityFTF.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityFTF.thirdDistance = imageBlock.ThirdDistance;
                imageEntityFTF.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityFTF.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityVirtualHRA = new ImageEntity();
                imageEntityVirtualHRA.Name = "virtualHRA";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityVirtualHRA.Name, coolingType);
                int virtualWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int virtualHight = Convert.ToInt32((imageBlock.ImageHeight-2)/2 * factor);
                imageEntityVirtualHRA.Rect = new Rectangle(imageEntityFTF.Rect.X + imageEntityFTF.Rect.Width + 1, imageEntityFTF.Rect.Y, virtualWidth, virtualHight);
                imageEntityVirtualHRA.Url = ImageBoxService.getImageUrl(imageEntityVirtualHRA.Name);
                imageEntityVirtualHRA.Type = "row";
                imageEntityVirtualHRA.Text = imageBlock.Text;
                imageEntityVirtualHRA.firstDistance = imageBlock.FirstDistance;
                imageEntityVirtualHRA.secondDistance = imageBlock.SecondDistance;
                imageEntityVirtualHRA.coolingType = coolingType;
                imageEntityVirtualHRA.isSelected = false;
                imageEntityVirtualHRA.moduleTag = "102-" + imageBlock.ParentName;
                imageEntityVirtualHRA.parentName = imageBlock.ParentName;
                imageEntityVirtualHRA.Guid = Guid.NewGuid().ToString("N");
                imageEntityVirtualHRA.orderId = FrontPhotoImageModelService.orderId;
                imageEntityVirtualHRA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityVirtualHRA.thirdDistance = imageBlock.ThirdDistance;
                imageEntityVirtualHRA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityVirtualHRA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityCLF = new ImageEntity();

                imageEntityCLF.Name = "CLF";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityCLF.Name, coolingType);
                int clfWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int clfHeight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityCLF.Url = ImageBoxService.getImageUrl(imageEntityCLF.Name);
                imageEntityCLF.Rect = new Rectangle(imageEntityVirtualHRA.Rect.X + imageEntityVirtualHRA.Rect.Width + 1, imageEntityVirtualHRA.Rect.Y, clfWidth, clfHeight);
                imageEntityCLF.Type = "row";
                imageEntityCLF.Text = imageBlock.Text;
                imageEntityCLF.firstDistance = imageBlock.FirstDistance;
                imageEntityCLF.secondDistance = imageBlock.SecondDistance;
                imageEntityCLF.coolingType = coolingType;
                imageEntityCLF.isSelected = false;
                imageEntityCLF.moduleTag = "103-" + imageBlock.ParentName;
                imageEntityCLF.parentName = imageBlock.ParentName;
                imageEntityCLF.Guid = Guid.NewGuid().ToString("N");
                imageEntityCLF.orderId = FrontPhotoImageModelService.orderId;
                imageEntityCLF.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityCLF.thirdDistance = imageBlock.ThirdDistance;
                imageEntityCLF.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityCLF.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntitySFA = new ImageEntity();
                if (coolingType <= 14)
                {
                    imageEntitySFA.Name = "SFA";
                }
                else
                {
                    imageEntitySFA.Name = "SDB";
                }
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntitySFA.Name, coolingType);
                int sfaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int sfaHeight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntitySFA.Url = ImageBoxService.getImageUrl(imageEntitySFA.Name);
                imageEntitySFA.Rect = new Rectangle(imageEntityCLF.Rect.X + imageEntityCLF.Rect.Width + 1, imageEntityCLF.Rect.Y, sfaWidth, sfaHeight);
                imageEntitySFA.Type = "row";
                imageEntitySFA.Text = imageBlock.Text;
                imageEntitySFA.firstDistance = imageBlock.FirstDistance;
                imageEntitySFA.secondDistance = imageBlock.SecondDistance;
                imageEntitySFA.coolingType = coolingType;
                imageEntitySFA.isSelected = false;
                imageEntitySFA.moduleTag = "104-" + imageBlock.ParentName;
                imageEntitySFA.parentName = imageBlock.ParentName;
                imageEntitySFA.Guid = Guid.NewGuid().ToString("N");
                imageEntitySFA.orderId = FrontPhotoImageModelService.orderId;
                imageEntitySFA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntitySFA.thirdDistance = imageBlock.ThirdDistance;
                imageEntitySFA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntitySFA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityPEA = new ImageEntity();
                imageEntityPEA.Name = "PEA";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityPEA.Name, coolingType);
                int peaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int peaHight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityPEA.Rect = new Rectangle(imageEntityFTF.Rect.X, imageEntityFTF.Rect.Y - imageEntityFTF.Rect.Height-2, peaWidth, peaHight);
                imageEntityPEA.Url = ImageBoxService.getImageUrl(imageEntityPEA.Name);
                imageEntityPEA.Type = "row";
                imageEntityPEA.Text = imageBlock.Text;
                imageEntityPEA.firstDistance = imageBlock.FirstDistance;
                imageEntityPEA.secondDistance = imageBlock.SecondDistance;
                imageEntityPEA.coolingType = coolingType;
                imageEntityPEA.isSelected = false;
                imageEntityPEA.moduleTag = "201-" + imageBlock.ParentName;
                imageEntityPEA.parentName = imageBlock.ParentName;
                imageEntityPEA.Guid = Guid.NewGuid().ToString("N");
                imageEntityPEA.orderId = FrontPhotoImageModelService.orderId;
                imageEntityPEA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityPEA.thirdDistance = imageBlock.ThirdDistance;
                imageEntityPEA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityPEA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityHRA = new ImageEntity();
                imageEntityHRA.Name = "HRA";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityHRA.Name, coolingType);
                int hraWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int hraHight = Convert.ToInt32((imageBlock.ImageHeight-2)* factor+2);
                imageEntityHRA.Rect = new Rectangle(imageEntityPEA.Rect.X + imageEntityPEA.Rect.Width+1, imageEntityPEA.Rect.Y, hraWidth, hraHight);
                imageEntityHRA.Url = ImageBoxService.getImageUrl(imageEntityHRA.Name);
                imageEntityHRA.Type = "row";
                imageEntityHRA.Text = imageBlock.Text;
                imageEntityHRA.firstDistance = imageBlock.FirstDistance;
                imageEntityHRA.secondDistance = imageBlock.SecondDistance;
                imageEntityHRA.coolingType = coolingType;
                imageEntityHRA.isSelected = false;
                imageEntityHRA.moduleTag = "202-" + imageBlock.ParentName;
                imageEntityHRA.parentName = imageBlock.ParentName;
                imageEntityHRA.Guid = Guid.NewGuid().ToString("N");
                imageEntityHRA.orderId = FrontPhotoImageModelService.orderId;
                imageEntityHRA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityHRA.thirdDistance = imageBlock.ThirdDistance;
                imageEntityHRA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityHRA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                ImageEntity imageEntityFTA = new ImageEntity();
                imageEntityFTA.Name = "FTA";
                imageBlock = ImageBlockBLL.getImageBlocksByNames(imageEntityFTA.Name, coolingType);
                int ftaWidth = Convert.ToInt32(imageBlock.ImageLength * factor);
                int ftaHight = Convert.ToInt32(imageBlock.ImageHeight * factor);
                imageEntityFTA.Rect = new Rectangle(imageEntityHRA.Rect.X + imageEntityHRA.Rect.Width + 1, imageEntityHRA.Rect.Y, ftaWidth, ftaHight);
                imageEntityFTA.Url = ImageBoxService.getImageUrl(imageEntityFTA.Name);
                imageEntityFTA.Type = "row";
                imageEntityFTA.Text = imageBlock.Text;
                imageEntityFTA.firstDistance = imageBlock.FirstDistance;
                imageEntityFTA.secondDistance = imageBlock.SecondDistance;
                imageEntityFTA.coolingType = coolingType;
                imageEntityFTA.isSelected = false;
                imageEntityFTA.moduleTag = "203-" + imageBlock.ParentName;
                imageEntityFTA.parentName = imageBlock.ParentName;
                imageEntityFTA.Guid = Guid.NewGuid().ToString("N");
                imageEntityFTA.orderId = FrontPhotoImageModelService.orderId;
                imageEntityFTA.imageWidth = Convert.ToInt32(imageBlock.ImageWidth);
                imageEntityFTA.thirdDistance = imageBlock.ThirdDistance;
                imageEntityFTA.topViewFirstDistance = imageBlock.TopViewFirstDistance;
                imageEntityFTA.topViewSecondDistance = imageBlock.TopViewSecondDistance;

                imageBoxList.Add(imageEntityFTF);
                imageBoxList.Add(imageEntityVirtualHRA);
                imageBoxList.Add(imageEntityCLF);
                imageBoxList.Add(imageEntitySFA);
                imageBoxList.Add(imageEntityPEA);
                imageBoxList.Add(imageEntityHRA);
                imageBoxList.Add(imageEntityFTA);
            }
            return imageBoxList;
        }
示例#15
0
        //组图算法
        public static List<ImageEntity> calculateImageEntityPosition(List<ImageEntity> imageBoxList, ImageEntity srcImageEntity, ImageEntity destImageEntity, string mirrorDirection)
        {
            //定义sortRangeList用来存储设好坐标的PictureBox
            List<ImageEntity> sortRangeList = new List<ImageEntity>();
            if (srcImageEntity.Type == "row")
            {
                if (RightImageRangeType.imageRangeTypeArray[0].Equals(srcImageEntity.Name))
                {
                    //在两层元素前面的元素整体左移
                    if (destImageEntity.Rect.X < srcImageEntity.Rect.X)
                    {
                        for (int i = upCrossElement; i > upFirstElement; i--)
                        {
                            imageBoxList.ElementAt(i - 1).Rect = new Rectangle(imageBoxList.ElementAt(i - 1).Rect.X - (srcImageEntity.Rect.X - destImageEntity.Rect.X), imageBoxList.ElementAt(i - 1).Rect.Y, imageBoxList.ElementAt(i - 1).Rect.Width, imageBoxList.ElementAt(i - 1).Rect.Height);
                        }
                    }
                    ////在两层元素前面的元素整体右移
                    else
                    {
                        for (int i = upCrossElement + 1; i < imageBoxList.Count; i++)
                        {
                            imageBoxList.ElementAt(i).Rect = new Rectangle(imageBoxList.ElementAt(i).Rect.X + (destImageEntity.Rect.X - srcImageEntity.Rect.X), imageBoxList.ElementAt(i).Rect.Y, imageBoxList.ElementAt(i).Rect.Width, imageBoxList.ElementAt(i).Rect.Height);
                        }
                    }
                    removeListImageEntity(imageBoxList, srcImageEntity);
                    removeListImageEntity(imageBoxList, srcImageEntity.Rect.X, "virtualHRA");
                }
                else
                {
                    removeListImageEntity(imageBoxList, srcImageEntity);
                }

            }
            //添加新元素
            if (RightImageRangeType.imageRangeTypeArray[0].Equals(destImageEntity.Name))
            {

                ImageEntity virtualImageEntity = new ImageEntity();
                virtualImageEntity.Name = "virtualHRA";
                virtualImageEntity.Rect = new Rectangle(destImageEntity.Rect.X, destImageEntity.Rect.Y + (destImageEntity.Rect.Height-2)/2 +2, destImageEntity.Rect.Width, (destImageEntity.Rect.Height-2)/2);
                virtualImageEntity.Url = destImageEntity.Url;
                virtualImageEntity.Type = destImageEntity.Type;
                virtualImageEntity.coolingType = destImageEntity.coolingType;
                virtualImageEntity.orderId = destImageEntity.orderId;
                virtualImageEntity.moduleTag = destImageEntity.moduleTag;
                virtualImageEntity.parentName = destImageEntity.parentName;
                virtualImageEntity.firstDistance = destImageEntity.firstDistance;
                virtualImageEntity.secondDistance = destImageEntity.secondDistance;
                virtualImageEntity.topViewFirstDistance = destImageEntity.topViewFirstDistance;
                virtualImageEntity.topViewSecondDistance = destImageEntity.topViewSecondDistance;
                virtualImageEntity.imageWidth = destImageEntity.imageWidth;
                //向imageList中加入两个ImageEntity
                imageBoxList.Add(virtualImageEntity);
                imageBoxList.Add(destImageEntity);
            }
            else
            {
                imageBoxList.Add(destImageEntity);
            }

            //重新排序

            imageBoxList = getNewDoubleList(imageBoxList, mirrorDirection);

            for (int i = 0; i < imageBoxList.Count; i++)
            {

                if (i == 0)
                {
                    //记录双层元素的x坐标
                    if (imageBoxList.ElementAt(i).Name.Equals("virtualHRA"))
                    {
                        // xCrossPosition = imageBoxList.ElementAt(i).Rect.X;
                        xCrossPosition = leftStartX;
                    }
                    //设置好初始坐标
                    imageBoxList.ElementAt(i).Rect = new Rectangle(leftStartX, leftStartY, imageBoxList.ElementAt(i).Rect.Width, imageBoxList.ElementAt(i).Rect.Height);
                    sortRangeList.Add(imageBoxList.ElementAt(i));
                }
                else
                {
                    //PictureBox tempPbBefor=tempPaintImageList.ElementAt(i-1).Value;
                    //不存在两层元素
                    if (upCrossElement == -1)
                    {
                        ImageEntity tempPbAfter = imageBoxList.ElementAt(i);
                        ImageEntity tempPbBefor;
                        if (i < upFirstElement)
                        {
                            //右边镜像
                            if (mirrorDirection.Equals("mirrorRight"))
                            {
                                //以右边基准
                                //tempPbBefor = imageBoxList.ElementAt(i - 1);
                                ImageEntity mirrorRightDown = imageBoxList.ElementAt(downLastElement);
                                mirrorRightDown.Rect = new Rectangle(leftStartX, leftStartY, mirrorRightDown.Rect.Width, mirrorRightDown.Rect.Height);
                                for (int j = downLastElement; j > 0; j--)
                                {
                                    ImageEntity tempMirrorRightPbBefor = imageBoxList.ElementAt(j);
                                    ImageEntity tempMrrorRightPbAfter = imageBoxList.ElementAt(j - 1);
                                    tempMrrorRightPbAfter.Rect = new Rectangle(tempMirrorRightPbBefor.Rect.X - tempMrrorRightPbAfter.Rect.Width - 1, tempMirrorRightPbBefor.Rect.Y, tempMrrorRightPbAfter.Rect.Width, tempMrrorRightPbAfter.Rect.Height);
                                }
                                i = downLastElement;
                            }
                            else
                            {
                                tempPbBefor = imageBoxList.ElementAt(i - 1);
                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                            }
                        }
                        else
                        {
                            //单层情况
                            if (upFirstElement == -1)
                            {
                                //右边镜像
                                if (mirrorDirection.Equals("mirrorRight"))
                                {
                                    //以右边基准
                                    ImageEntity mirrorRightDown = imageBoxList.ElementAt(downLastElement);
                                    mirrorRightDown.Rect = new Rectangle(leftStartX, leftStartY, mirrorRightDown.Rect.Width, mirrorRightDown.Rect.Height);
                                    for (int j = downLastElement; j > 0;j-- )
                                    {
                                       ImageEntity tempMirrorRightPbBefor = imageBoxList.ElementAt(j);
                                       ImageEntity tempMrrorRightPbAfter = imageBoxList.ElementAt(j - 1);
                                       tempMrrorRightPbAfter.Rect = new Rectangle(tempMirrorRightPbBefor.Rect.X - tempMrrorRightPbAfter.Rect.Width - 1, tempMirrorRightPbBefor.Rect.Y, tempMrrorRightPbAfter.Rect.Width, tempMrrorRightPbAfter.Rect.Height);
                                    }
                                    i = downLastElement;
                                }
                                else
                                {
                                    tempPbBefor = imageBoxList.ElementAt(i - 1);
                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                }
                            }
                            //双层情况
                            else
                            {
                                if (i == upFirstElement)
                                {
                                    //做上层自动移动
                                    if (srcImageEntity.Type == "over")
                                    {
                                        if (upFirstElement < imageBoxList.Count-1)
                                        {
                                            if (mirrorDirection.Equals("mirrorRight"))
                                            {
                                                //从左面添加
                                                if (destImageEntity.Rect.X == imageBoxList.ElementAt(upFirstElement).Rect.X)
                                                {
                                                    tempPbBefor = imageBoxList.ElementAt(upFirstElement + 1);
                                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                }
                                                //右边添加
                                                else
                                                {
                                                    tempPbBefor = imageBoxList.ElementAt(upFirstElement);
                                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                }
                                            }
                                            else
                                            {
                                                //从左面添加
                                                if (destImageEntity.Rect.X == imageBoxList.ElementAt(upFirstElement).Rect.X)
                                                {
                                                    tempPbBefor = imageBoxList.ElementAt(upFirstElement+1);
                                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X-tempPbAfter.Rect.Width-1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                }
                                                //右边添加
                                                else
                                                {
                                                    //左边镜像,上层以左边为标准e(添加的事上层左边)
                                                    if (destImageEntity.Rect.X == imageBoxList.ElementAt(imageBoxList.Count - 1).Rect.X && destImageEntity.Rect.Y == imageBoxList.ElementAt(imageBoxList.Count - 1).Rect.Y)
                                                    {
                                                        ImageEntity mirrorLeftUpBefor = imageBoxList.ElementAt(imageBoxList.Count - 2);
                                                        ImageEntity mirrorLeftUpAfter = imageBoxList.ElementAt(imageBoxList.Count - 1);
                                                        mirrorLeftUpAfter.Rect = new Rectangle(mirrorLeftUpBefor.Rect.X, mirrorLeftUpBefor.Rect.Y, mirrorLeftUpAfter.Rect.Width, mirrorLeftUpAfter.Rect.Height);
                                                        for (int j = imageBoxList.Count - 1; j > upFirstElement; j--)
                                                        {
                                                            ImageEntity mirrorLeftTempPbBefor = imageBoxList.ElementAt(j);
                                                            ImageEntity mirrorLeftTmepPbAfter = imageBoxList.ElementAt(j - 1);
                                                            mirrorLeftTmepPbAfter.Rect = new Rectangle(mirrorLeftTempPbBefor.Rect.X - mirrorLeftTmepPbAfter.Rect.Width - 1, mirrorLeftTempPbBefor.Rect.Y, mirrorLeftTmepPbAfter.Rect.Width, mirrorLeftTmepPbAfter.Rect.Height);
                                                        }
                                                        break;
                                                    }
                                                    //添加为下层左边或右边或等其他情况时
                                                    else
                                                    {
                                                        //ImageEntity mirrorLeftUpBefor = imageBoxList.ElementAt(imageBoxList.Count - 2);
                                                        ImageEntity mirrorLeftUpAfter = imageBoxList.ElementAt(imageBoxList.Count - 1);
                                                        mirrorLeftUpAfter.Rect = new Rectangle(mirrorLeftUpAfter.Rect.X, mirrorLeftUpAfter.Rect.Y, mirrorLeftUpAfter.Rect.Width, mirrorLeftUpAfter.Rect.Height);
                                                        for (int j = imageBoxList.Count - 1; j > upFirstElement; j--)
                                                        {
                                                            ImageEntity mirrorLeftTempPbBefor = imageBoxList.ElementAt(j);
                                                            ImageEntity mirrorLeftTmepPbAfter = imageBoxList.ElementAt(j - 1);
                                                            mirrorLeftTmepPbAfter.Rect = new Rectangle(mirrorLeftTempPbBefor.Rect.X - mirrorLeftTmepPbAfter.Rect.Width - 1, mirrorLeftTempPbBefor.Rect.Y, mirrorLeftTmepPbAfter.Rect.Width, mirrorLeftTmepPbAfter.Rect.Height);
                                                        }
                                                        break;
                                                    }
                                                }
                                            }

                                        }
                                        else
                                        {
                                            if (mirrorDirection.Equals("mirrorRight"))
                                            {
                                                tempPbBefor = imageBoxList.ElementAt(0);
                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            }
                                            else
                                            {
                                                tempPbBefor = imageBoxList.ElementAt(upFirstElement-1);
                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X+tempPbBefor.Rect.Width-tempPbAfter.Rect.Width, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            }
                                        }
                                    }
                                    else if (srcImageEntity.Type == "row")
                                    {

                                        if (i == imageBoxList.Count - 1)
                                        {
                                            if (destImageEntity.Rect.X == imageBoxList.ElementAt(i).Rect.X && destImageEntity.Rect.Y == imageBoxList.ElementAt(i).Rect.Y && destImageEntity.Name == imageBoxList.ElementAt(i).Name)
                                            {
                                                int upMoveLen = destImageEntity.Rect.X - srcImageEntity.Rect.X;
                                                int leftOrRightWidth = 0;
                                                //右移
                                                if (upMoveLen > 0)
                                                {
                                                    leftOrRightWidth = imageBoxList.ElementAt(upFirstElement - 1).Rect.X + imageBoxList.ElementAt(upFirstElement - 1).Rect.Width - srcImageEntity.Rect.X;
                                                    //消除边缘悬挂情况
                                                    upMoveLen += srcImageEntity.Rect.Width;
                                                    if (upMoveLen >= leftOrRightWidth)
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(upFirstElement - 1);
                                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width - tempPbAfter.Rect.Width, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                    }
                                                    else
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(upFirstElement - 1);
                                                        tempPbAfter.Rect = new Rectangle(destImageEntity.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);

                                                    }
                                                }
                                                //左移
                                                else
                                                {
                                                    leftOrRightWidth = srcImageEntity.Rect.X - imageBoxList.ElementAt(0).Rect.X;
                                                    int upLeftLen = srcImageEntity.Rect.X - destImageEntity.Rect.X;
                                                    if (upLeftLen >= leftOrRightWidth)
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(0);
                                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                    }
                                                    else
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(0);
                                                        tempPbAfter.Rect = new Rectangle(destImageEntity.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                //在原位置不变
                                                tempPbBefor = imageBoxList.ElementAt(i);
                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            }

                                        }
                                        else
                                        {
                                            //这里继续做,这么做是因为destImageEntiy已经加入了imageboxlist,如果if执行说明upFirstElement且此时移动了它
                                            if (destImageEntity.Rect.X == imageBoxList.ElementAt(i).Rect.X && destImageEntity.Rect.Y == imageBoxList.ElementAt(i).Rect.Y && destImageEntity.Name == imageBoxList.ElementAt(i).Name)
                                            {
                                                int upMoveLen = srcImageEntity.Rect.X - destImageEntity.Rect.X;
                                                int leftWidth = 0;
                                                if (upMoveLen >=0)
                                                {
                                                    leftWidth = srcImageEntity.Rect.X - imageBoxList.ElementAt(0).Rect.X;
                                                    if (srcImageEntity.Rect.X <= imageBoxList.ElementAt(0).Rect.X)
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(0);
                                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                    }
                                                    else
                                                    {
                                                        if (destImageEntity.Rect.X >= imageBoxList.ElementAt(0).Rect.X)
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(0);
                                                            tempPbAfter.Rect = new Rectangle(destImageEntity.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        }
                                                        else
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(0);
                                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        }
                                                        for (int j = upFirstElement; j < imageBoxList.Count - 1; j++)
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(j);
                                                            tempPbAfter = imageBoxList.ElementAt(j + 1);
                                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        }
                                                        //这里已经一次性将后面的元素排好故要跳出整个for循环
                                                        break;
                                                    }
                                                }
                                                else
                                                {
                                                    //左移超出了边界,左对准
                                                    tempPbBefor = imageBoxList.ElementAt(0);
                                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);

                                                }
                                            }
                                            else
                                            {
                                                //tempPbBefor = imageBoxList.ElementAt(0);
                                                //tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                //此时没有移动upFirstElement,保持不动
                                                tempPbBefor = imageBoxList.ElementAt(upFirstElement);
                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            }

                                        }
                                    }
                                }
                                else
                                {
                                    if (i == imageBoxList.Count - 1)
                                    {
                                        if (srcImageEntity.Type == "over")
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(i - 1);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                        }
                                        else if (srcImageEntity.Type == "row")
                                        {
                                            if (destImageEntity.Rect.X == imageBoxList.ElementAt(i).Rect.X && destImageEntity.Rect.Y == imageBoxList.ElementAt(i).Rect.Y && destImageEntity.Name == imageBoxList.ElementAt(i).Name)
                                            {
                                                int upMoreMoveLen = destImageEntity.Rect.X - srcImageEntity.Rect.X;
                                                //7-31修改
                                                int rightWidth = imageBoxList.ElementAt(upFirstElement - 1).Rect.Width + imageBoxList.ElementAt(upFirstElement - 1).Rect.X - srcImageEntity.Rect.X-srcImageEntity.Rect.Width;
                                                if (upMoreMoveLen > 0)
                                                {
                                                    if (upMoreMoveLen >= rightWidth)
                                                    {
                                                        //最后一个元素的位置没有超出下层时
                                                        //7-31修改
                                                        //if (srcImageEntity.Rect.X < imageBoxList.ElementAt(upFirstElement - 1).Rect.X)
                                                        if ((destImageEntity.Rect.X+destImageEntity.Rect.Width) > imageBoxList.ElementAt(upFirstElement - 1).Rect.X)
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(upFirstElement - 1);
                                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width - tempPbAfter.Rect.Width, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                            for (int j = i; j > upFirstElement; j--)
                                                            {
                                                                tempPbBefor = imageBoxList.ElementAt(j);
                                                                tempPbAfter = imageBoxList.ElementAt(j - 1);
                                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X - tempPbAfter.Rect.Width - 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(i - 1);
                                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        tempPbBefor = imageBoxList.ElementAt(upFirstElement - 1);
                                                        tempPbAfter.Rect = new Rectangle(destImageEntity.Rect.X, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        for (int j = i; j > upFirstElement; j--)
                                                        {
                                                            tempPbBefor = imageBoxList.ElementAt(j);
                                                            tempPbAfter = imageBoxList.ElementAt(j - 1);
                                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X - tempPbAfter.Rect.Width - 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    tempPbBefor = imageBoxList.ElementAt(i - 1);
                                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                                }
                                            }
                                            else
                                            {
                                                tempPbBefor = imageBoxList.ElementAt(i - 1);
                                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            }

                                        }
                                    }
                                    else
                                    {
                                        tempPbBefor = imageBoxList.ElementAt(i - 1);
                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                    }

                                }

                            }

                        }
                        //其他已经拖动好的PictureBox,存放其中
                        sortRangeList.Add(tempPbAfter);
                    }
                    //存在两层元素
                    else
                    {
                        ImageEntity tempPbAfter = imageBoxList.ElementAt(i);
                        ImageEntity tempPbBefor;
                        if (i < upFirstElement)
                        {

                            //右边镜像
                            if (mirrorDirection.Equals("mirrorRight"))
                            {
                                //以右边基准
                                ImageEntity mirrorRightDown = imageBoxList.ElementAt(downLastElement);
                                mirrorRightDown.Rect = new Rectangle(leftStartX, leftStartY, mirrorRightDown.Rect.Width, mirrorRightDown.Rect.Height);
                                if (mirrorRightDown.Name.Equals("virtualHRA"))
                                {
                                    xCrossPosition = mirrorRightDown.Rect.X;
                                }
                                for (int j = downLastElement; j > 0; j--)
                                {
                                    ImageEntity tempMirrorRightPbBefor = imageBoxList.ElementAt(j);
                                    ImageEntity tempMrrorRightPbAfter = imageBoxList.ElementAt(j - 1);
                                    tempMrrorRightPbAfter.Rect = new Rectangle(tempMirrorRightPbBefor.Rect.X - tempMrrorRightPbAfter.Rect.Width - 1, tempMirrorRightPbBefor.Rect.Y, tempMrrorRightPbAfter.Rect.Width, tempMrrorRightPbAfter.Rect.Height);
                                    if (tempMrrorRightPbAfter.Name.Equals("virtualHRA"))
                                    {
                                        xCrossPosition = tempMrrorRightPbAfter.Rect.X;
                                    }
                                }
                                i = downLastElement;
                            }
                            else
                            {
                                tempPbBefor = imageBoxList.ElementAt(i - 1);
                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);

                                //记录双层元素的x坐标
                                if (tempPbAfter.Name.Equals("virtualHRA"))
                                {
                                    xCrossPosition = tempPbAfter.Rect.X;
                                }
                                sortRangeList.Add(tempPbAfter);
                            }

                        }
                        else
                        {
                            if (i >= upFirstElement)
                            {
                                //此时要以crossElement元素为参照物
                                if (upCrossElement == upFirstElement && i == upFirstElement)
                                {
                                    tempPbBefor = imageBoxList.ElementAt(0);
                                    tempPbAfter.Rect = new Rectangle(xCrossPosition, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                    sortRangeList.Add(tempPbAfter);
                                }
                                else
                                {
                                    //将cross元素前边的元素一次性计算完
                                    if (i < upCrossElement)
                                    {
                                        for (int j = upCrossElement; j > upFirstElement; j--)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(j);
                                            if (j == upCrossElement)
                                            {
                                                tempPbBefor.Rect = new Rectangle(xCrossPosition, imageBoxList.ElementAt(0).Rect.Y - imageBoxList.ElementAt(0).Rect.Height - 2, tempPbBefor.Rect.Width, tempPbBefor.Rect.Height);
                                            }
                                            tempPbAfter = imageBoxList.ElementAt(j - 1);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X - tempPbAfter.Rect.Width - 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }
                                        i = upCrossElement - 1;
                                    }
                                    //计算cross元素后边元素的位置
                                    else
                                    {
                                        if (i == upCrossElement)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(i);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }
                                        else if (i > upCrossElement)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(i - 1);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width+1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }

                                    }
                                }
                            }
                        }
                        //sortRangeList.Add(tempPbAfter);
                    }
                }
            }
            //复原xCrossPosition
            xCrossPosition = -1;
            // imageBoxList.Clear();
            // imageBoxList = sortRangeList;
            return imageBoxList;
        }
示例#16
0
        void CustomForm_MouseUp(object sender, MouseEventArgs e)
        {
            //设置矩形框标记为false,即不在绘制矩形框
            rectExist = false;
            //如果是单击事件
            if (e.X == downPoint.X && e.Y == downPoint.Y)
            {
                //如果当前的点击在图片区域内,则形成一个矩形框,此处作为判断并列的图块的判断
                if (rowImageEntities.Count > 0)
                {
                    foreach (var imageEntity in rowImageEntities)
                    {
                        if (imageEntity.HitTest(downPoint))
                        {
                            //消除virtualHRA影响
                            if (imageEntity.Name.Equals("virtualHRA"))
                            {
                                foreach (var hraEntity in rowImageEntities)
                                {
                                    if (hraEntity.Name.Equals(RightImageRangeType.imageRangeType.ElementAt(0).ToString()))
                                    {
                                        //如果双击则触发事件
                                        if (OnEntityClick != null)
                                            OnEntityClick(hraEntity);
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                //如果双击则触发事件
                                if (OnEntityClick != null)
                                    OnEntityClick(imageEntity);
                                return;
                            }

                        }
                    }
                }
                //如果在重叠图块内
                if (overlapImageEntities != null && overlapImageEntities.Count > 0)
                {
                    var lastImageEntity = overlapImageEntities.Last();
                    if (lastImageEntity.HitTest(downPoint))
                    {
                        //如果双击则触发事件
                        if (OnEntityClick != null)
                            OnEntityClick(lastImageEntity);
                        return;
                    }
                }
            }

            //如果当前未选中任何图块不做事情,如果选中如下:
            if (isHitted)
            {
                //对目标图块赋值
                ImageEntity destImageEntity = new ImageEntity();
                destImageEntity.Rect = selectedRectangle;
                destImageEntity.Name = selectedImageEntity.Name;
                destImageEntity.Type = "row";
                destImageEntity.Url = selectedImageEntity.Url;
                destImageEntity.coolingType = selectedImageEntity.coolingType;
                destImageEntity.firstDistance = selectedImageEntity.firstDistance;
                destImageEntity.secondDistance = selectedImageEntity.secondDistance;
                destImageEntity.Text = selectedImageEntity.Text;
                destImageEntity.parentName = selectedImageEntity.parentName;
                destImageEntity.orderId = selectedImageEntity.orderId;
                destImageEntity.moduleTag = selectedImageEntity.moduleTag;
                destImageEntity.isSelected = selectedImageEntity.isSelected;
                destImageEntity.Guid = selectedImageEntity.Guid;
                destImageEntity.thirdDistance = selectedImageEntity.thirdDistance;
                destImageEntity.topViewFirstDistance = selectedImageEntity.topViewFirstDistance;
                destImageEntity.topViewSecondDistance = selectedImageEntity.topViewSecondDistance;
                destImageEntity.imageWidth = selectedImageEntity.imageWidth;
                //触发移动事件
                if (OnEntityMove != null)
                    OnEntityMove(selectedImageEntity, destImageEntity);

                //if (selectedImageEntity.Type.Equals("over"))
                //{
                //    selectedImageEntity.Type = "row";
                //    //rowImageEntities.Add(selectedImageEntity);
                //    //overlapImageEntities.Remove(selectedImageEntity);
                //}
                //selectedImageEntity.Rect = selectedRectangle;
                isHitted = false;
            }

            this.Invalidate();
        }
示例#17
0
        //根据图片绘制图形
        private void DrawImageRect(PaintEventArgs e, ImageEntity imageEntity)
        {
            if (!imageEntity.Name.Equals("virtualHRA"))
            {
                // Create image.

                if (FrontPhotoService.mirrorDirection.Equals("mirrorRight"))
                {
                    Image newImage = Image.FromFile(imageEntity.Url);
                    // Draw image to screen.
                    e.Graphics.DrawImage(newImage, imageEntity.Rect);
                }
                else
                {
                    Image newImage = Image.FromFile(imageEntity.Url);
                    Bitmap bmp = new Bitmap(newImage);
                    bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    e.Graphics.DrawImage(bmp, imageEntity.Rect);
                }

            }
        }
示例#18
0
        //以左边对齐删除算法
        public static List<ImageEntity> deleteImageEntityPosition(List<ImageEntity> imageBoxList,ImageEntity deleteImageEntity,string mirrorDirection)
        {
            //定义sortRangeList用来存储设好坐标的PictureBox
            List<ImageEntity> sortRangeList = new List<ImageEntity>();
            //判断 deleteImageEntity是否为第一个
            bool isDelUpFirst = isDeleteUpFirstElement(imageBoxList, deleteImageEntity);

            if (RightImageRangeType.imageRangeTypeArray[0].Equals(deleteImageEntity.Name))
            {
                removeListImageEntity(imageBoxList, deleteImageEntity);
                removeListImageEntity(imageBoxList, deleteImageEntity.Rect.X, "virtualHRA");
            }
            else
            {
                removeListImageEntity(imageBoxList, deleteImageEntity);
            }
            //重新排序

            imageBoxList = getNewDoubleList(imageBoxList, mirrorDirection);

            for (int i = 0; i < imageBoxList.Count; i++)
            {

                if (i == 0)
                {
                    //记录双层元素的x坐标
                    if (imageBoxList.ElementAt(i).Name.Equals("virtualHRA"))
                    {
                        // xCrossPosition = imageBoxList.ElementAt(i).Rect.X;
                        xCrossPosition = leftStartX;
                    }
                    //设置好初始坐标
                    imageBoxList.ElementAt(i).Rect = new Rectangle(leftStartX, leftStartY, imageBoxList.ElementAt(i).Rect.Width, imageBoxList.ElementAt(i).Rect.Height);
                    sortRangeList.Add(imageBoxList.ElementAt(i));
                }
                else
                {
                    //PictureBox tempPbBefor=tempPaintImageList.ElementAt(i-1).Value;
                    //不存在两层元素
                    if (upCrossElement == -1)
                    {
                        ImageEntity tempPbAfter = imageBoxList.ElementAt(i);
                        ImageEntity tempPbBefor;
                        if (i < upFirstElement)
                        {
                            //右边镜像
                            if (mirrorDirection.Equals("mirrorRight"))
                            {
                                //以右边基准
                                //tempPbBefor = imageBoxList.ElementAt(i - 1);
                                ImageEntity mirrorRightDown = imageBoxList.ElementAt(downLastElement);
                                mirrorRightDown.Rect = new Rectangle(mirrorRightDown.Rect.X,leftStartY, mirrorRightDown.Rect.Width, mirrorRightDown.Rect.Height);
                                for (int j = downLastElement; j > 0; j--)
                                {
                                    ImageEntity tempMirrorRightPbBefor = imageBoxList.ElementAt(j);
                                    ImageEntity tempMrrorRightPbAfter = imageBoxList.ElementAt(j - 1);
                                    tempMrrorRightPbAfter.Rect = new Rectangle(tempMirrorRightPbBefor.Rect.X - tempMrrorRightPbAfter.Rect.Width - 1, tempMirrorRightPbBefor.Rect.Y, tempMrrorRightPbAfter.Rect.Width, tempMrrorRightPbAfter.Rect.Height);
                                }
                                i = downLastElement;
                            }
                            else
                            {
                                tempPbBefor = imageBoxList.ElementAt(i - 1);
                                tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                            }
                        }
                        else
                        {
                            //单层情况
                            if (upFirstElement == -1)
                            {
                                //右边镜像
                                if (mirrorDirection.Equals("mirrorRight"))
                                {
                                    //以右边基准
                                    //tempPbBefor = imageBoxList.ElementAt(i - 1);
                                    ImageEntity mirrorRightDown = imageBoxList.ElementAt(downLastElement);
                                    mirrorRightDown.Rect = new Rectangle(leftStartX, leftStartY, mirrorRightDown.Rect.Width, mirrorRightDown.Rect.Height);
                                    for (int j = downLastElement; j > 0; j--)
                                    {
                                        ImageEntity tempMirrorRightPbBefor = imageBoxList.ElementAt(j);
                                        ImageEntity tempMrrorRightPbAfter = imageBoxList.ElementAt(j - 1);
                                        tempMrrorRightPbAfter.Rect = new Rectangle(tempMirrorRightPbBefor.Rect.X - tempMrrorRightPbAfter.Rect.Width - 1, tempMirrorRightPbBefor.Rect.Y, tempMrrorRightPbAfter.Rect.Width, tempMrrorRightPbAfter.Rect.Height);
                                    }
                                    i = downLastElement;
                                }
                                else
                                {
                                    tempPbBefor = imageBoxList.ElementAt(i - 1);
                                    tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                }
                            }
                            //双层情况
                            else
                            {
                                if (i == upFirstElement)
                                {
                                    if (isDelUpFirst)
                                    {
                                        tempPbBefor = deleteImageEntity;
                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);

                                    }
                                    else
                                    {
                                        tempPbBefor = imageBoxList.ElementAt(upFirstElement);
                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                    }
                                 }
                                else
                                {
                                        tempPbBefor = imageBoxList.ElementAt(i - 1);
                                        tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                }

                            }

                        }
                        //其他已经拖动好的PictureBox,存放其中
                        sortRangeList.Add(tempPbAfter);
                    }
                    //存在两层元素
                    else
                    {
                        ImageEntity tempPbAfter = imageBoxList.ElementAt(i);
                        ImageEntity tempPbBefor;
                        if (i < upFirstElement)
                        {
                            tempPbBefor = imageBoxList.ElementAt(i - 1);
                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width + 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);

                            //记录双层元素的x坐标
                            if (tempPbAfter.Name.Equals("virtualHRA"))
                            {
                                xCrossPosition = tempPbAfter.Rect.X;
                            }
                            sortRangeList.Add(tempPbAfter);
                        }
                        else
                        {
                            if (i >= upFirstElement)
                            {
                                //此时要以crossElement元素为参照物
                                if (upCrossElement == upFirstElement && i == upFirstElement)
                                {
                                    tempPbBefor = imageBoxList.ElementAt(0);
                                    tempPbAfter.Rect = new Rectangle(xCrossPosition, tempPbBefor.Rect.Y - tempPbBefor.Rect.Height - 2, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                    sortRangeList.Add(tempPbAfter);
                                }
                                else
                                {
                                    //将cross元素前边的元素一次性计算完
                                    if (i < upCrossElement)
                                    {
                                        for (int j = upCrossElement; j > upFirstElement; j--)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(j);
                                            if (j == upCrossElement)
                                            {
                                                tempPbBefor.Rect = new Rectangle(xCrossPosition, imageBoxList.ElementAt(0).Rect.Y - imageBoxList.ElementAt(0).Rect.Height - 2, tempPbBefor.Rect.Width, tempPbBefor.Rect.Height);
                                            }
                                            tempPbAfter = imageBoxList.ElementAt(j - 1);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X - tempPbAfter.Rect.Width - 1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }
                                        i = upCrossElement - 1;
                                    }
                                    //计算cross元素后边元素的位置
                                    else
                                    {
                                        if (i == upCrossElement)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(i);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }
                                        else if (i > upCrossElement)
                                        {
                                            tempPbBefor = imageBoxList.ElementAt(i - 1);
                                            tempPbAfter.Rect = new Rectangle(tempPbBefor.Rect.X + tempPbBefor.Rect.Width+1, tempPbBefor.Rect.Y, tempPbAfter.Rect.Width, tempPbAfter.Rect.Height);
                                            sortRangeList.Add(tempPbAfter);
                                        }

                                    }
                                }
                            }
                        }
                        //sortRangeList.Add(tempPbAfter);
                    }
                }
            }
            //复原xCrossPosition
            xCrossPosition = -1;
            // imageBoxList.Clear();
            // imageBoxList = sortRangeList;
            return imageBoxList;
        }