예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender">箭头控件本体</param>
        /// <param name="lengthRat">长度</param>
        /// <param name="degree">相对水平向右顺时针旋转角度</param>
        /// <param name="tail">箭头尾部实际左边</param>
        /// <returns></returns>
        public static void DrawOneArrow(StraightArrowButton arrow, double lengthRat, double degree)
        {
            if (arrow != null && arrow.Parent != null && arrow.FromProcesses.Count == 1)
            {
                GraphicsPath path1 = new GraphicsPath();
                Point[]      result;
                Point[]      minMaxPoints;
                int          left, top, width, height;
                Point        tail;
                double       direction;

                while (true)
                {
                    direction    = (degree % 360 + 360) % 360;
                    result       = GetOneArrowPoints(lengthRat, degree);
                    minMaxPoints = GetMinMaxPoint(result);
                    tail         = arrow.FromProcesses[0].GetNextArrowTail(degree);

                    left   = tail.X + (minMaxPoints[0].X - (result[0].X + result[6].X) / 2); //矩形区域左边缘
                    top    = tail.Y + (minMaxPoints[0].Y - (result[0].Y + result[6].Y) / 2); //矩形区域上边缘
                    width  = minMaxPoints[1].X - minMaxPoints[0].X;                          //矩形区域宽度
                    height = minMaxPoints[1].Y - minMaxPoints[0].Y;                          //矩形区域高度

                    if (direction > 180 && (top - arrow.Parent.Top) < 8 * a)
                    {
                        //箭头上边缘过界,顺时针转动90度
                        degree += 90;
                        continue;
                    }
                    if ((direction < 90 || direction > 270) && ((left + width) + (ah + rw - 5) * a > arrow.Parent.Right))
                    {
                        //箭头右边缘过界,顺时针转动90度
                        degree += 90;
                        continue;
                    }
                    if ((direction > 90 && direction < 270) && (left - arrow.Parent.Left) < (ah + rw - 5) * a)
                    {
                        //箭头左边缘过界,逆时针转动90度
                        degree -= 90;
                        continue;
                    }
                    break;
                }

                path1.AddPolygon(result);
                arrow.Size   = new Size(width, height);
                arrow.Region = new Region(path1);
                arrow.Left   = left;
                arrow.Top    = top;
                arrow.ResetDegree(degree);
                arrow.ArrowTail = tail;

                //箭头头部坐标
                Point arrowHead = new Point(tail.X + (result [3].X - (result[0].X + result[6].X) / 2),
                                            tail.Y + (result[3].Y - (result[0].Y + result[6].Y) / 2));
                arrow.ArrowHead = arrowHead;
            }
        }
예제 #2
0
        private bool initFlowPicBox()
        {
            clear();
            string routeCode = "",
                   moCode    = "",
                   itemCode;

            object[] objs;

            if (string.IsNullOrEmpty(Convert.ToString(this.drownListMoCode.SelectedItemValue)))
            {
                return(false);
            }
            moCode = Convert.ToString(this.drownListMoCode.SelectedItemValue);
            if (string.IsNullOrEmpty(Convert.ToString(this.drownListRouteCode.SelectedItemValue)))
            {
                return(false);
            }
            routeCode = Convert.ToString(this.drownListRouteCode.SelectedItemValue);

            Messages msg = new Messages();

            if (m_DataCollectFacade == null)
            {
                m_DataCollectFacade = new DataCollectFacade(this.DataProvider);
            }
            try
            {
                //add
                string sourceRcard = m_DataCollectFacade.GetSourceCard(FormatHelper.CleanString(txtRcard.Text.ToUpper()), this.drownListMoCode.SelectedItemValue.ToString());
                //end
                //object objLastSimRe = m_DataCollectFacade.GetLastSimulationReport(FormatHelper.CleanString(sourceRcard));
                object objLastSimRe = m_DataCollectFacade.GetSimulationReport(this.drownListMoCode.SelectedItemValue.ToString(), FormatHelper.CleanString(sourceRcard));


                if (objLastSimRe == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$Error_CS_ID_Not_Exist"));
                    txtRcard.SelectAll();
                    txtRcard.Focus();
                    ApplicationRun.GetInfoForm().Add(msg);
                    return(false);
                }
                else
                {
                    SimulationReport currentSimRe = (SimulationReport)objLastSimRe;
                    itemCode = currentSimRe.ItemCode;

                    //查询当前途程工序捞TBLITEMROUTE2OP表
                    //QueryItemOpFlow(当前itemCode,当前途程Code);
                    objs = m_DataCollectFacade.QueryItemOpFlow(itemCode, routeCode);
                    if (objs == null)
                    {
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_No_Data_To_Display"));
                        //add by klaus 置焦点
                        txtRcard.SelectAll();
                        txtRcard.Focus();
                        return(false);
                    }

                    #region 画流程图
                    this.panelDrawFlow.Controls.Clear();
                    this.panelDrawFlow.Refresh();

                    StartButton btnStart = new StartButton();
                    this.panelDrawFlow.Controls.Add(btnStart);
                    btnStart.setProcessName(MutiLanguages.ParserString("$CS_Start"));
                    btnStart.Location = new Point(10, 30);
                    btnStart.DrawButton();

                    FunctionButton lastOne = btnStart;
                    FlowButton     btnFlow = new StraightArrowButton();
                    double         vdegree = 0;

                    ItemRoute2OP currentOP = null;

                    for (int i = 0; i < objs.Length; i++)
                    {
                        ItemRoute2OP itemRoute2Op = objs[i] as ItemRoute2OP;

                        btnFlow = lastOne.AddOutArrow(vdegree);
                        Operation op = (Operation) new BaseModelFacade(this.DataProvider).GetOperation(itemRoute2Op.OPCode);
                        lastOne = btnFlow.AddOutProcess(itemRoute2Op.OPCode);

                        lastOne.Tag       = itemRoute2Op.OPCode;
                        lastOne.ProcessID = op.OPDescription;
                        lastOne.DrawButton();
                        lastOne.BackColor = Color.Green;
                        lastOne.Click    += new EventHandler(btn_Click);

                        //string actionResult = m_DataCollectFacade.CheckOpIsExist(FormatHelper.CleanString(txtRcard.Text.Trim().ToUpper()), moCode, routeCode, itemRoute2Op.OPCode);
                        string actionResult = m_DataCollectFacade.CheckOpIsExist(sourceRcard, moCode, routeCode, itemRoute2Op.OPCode);
                        if (string.IsNullOrEmpty(actionResult))
                        {
                            lastOne.BackColor = Color.White;
                        }
                        else
                        {
                            if (actionResult == ProductStatus.GOOD)
                            {
                                lastOne.BackColor = Color.Green;
                            }
                            else
                            {
                                lastOne.BackColor = Color.Red;
                            }
                        }

                        if (itemRoute2Op.OPCode == currentSimRe.OPCode &&
                            itemRoute2Op.RouteCode == currentSimRe.RouteCode)
                        {
                            currentOP = (ItemRoute2OP)objs[i];
                            if (currentSimRe.Status == ProductStatus.GOOD)
                            {
                                lastOne.BackColor = Color.Green;
                            }
                            else
                            {
                                lastOne.BackColor = Color.Red;
                            }
                        }

                        #region 注释 Terry 2012-11-13
                        //如果途程里工序是从0开始,显示背景有问题。
                        //if ((currentOP != null) && (i > currentOP.OPSequence - 1))
                        //{
                        //    lastOne.BackColor = Color.WhiteSmoke;
                        //}
                        #endregion

                        if ((btnFlow as StraightArrowButton).Degree == 90)
                        {
                            vdegree = (vdegree + 180) % 360;
                        }
                    }
                    btnFlow = lastOne.AddOutArrow(vdegree);
                    EndButton btnEnd = btnFlow.AddEnd();
                    btnEnd.Text      = MutiLanguages.ParserString("$CS_End");
                    btnEnd.BackColor = lastOne.BackColor;
                    #endregion

                    return(true);
                }
            }
            catch (Exception ex)
            {
                msg.Add(new UserControl.Message(ex));
                ApplicationRun.GetInfoForm().Add(msg);
                txtRcard.Focus();
                return(false);
            }
        }