Ejemplo n.º 1
0
        /// <summary>
        /// 获取选中缺陷的位置
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        private string GetCurrentDefect(Point start)
        {
            var location = string.Empty;

            //根据偏移量计算坐标
            //start.X = Convert.ToInt32(start.X * scaleX);
            //start.Y = Convert.ToInt32(start.Y * scaleY);
            if (DefectList == null)
            {
                return(location);
            }

            var index = DefectList.FindIndex(s => s.Points.IsPointInPolygon(start));

            if (index > -1)
            {
                location = DefectList[index].Location;

                SelectDefect.Add(location);

                if (CurrentDefect != location)
                {
                    DefectChanged(new EventDefectArg()
                    {
                        Location = location
                    });
                }

                CurrentDefect = location;
            }
            else
            {
                index = DieLayoutList.FindIndex(s => s.Points.IsPointInPolygon(start));

                if (index > -1)
                {
                    location = DieLayoutList[index].X + "," + DieLayoutList[index].Y;

                    SelectGoodDie.Add(location);

                    if (CurrentDefect != location)
                    {
                        CurrentDefect = location;
                        ReDraw();
                    }
                }
            }

            return(location);
        }
        /// <summary>
        /// загрузка перечня дефектов для этой группы конструкций
        /// </summary>
        protected void LoadDefectList(int cgrConstr, List <CustomDefectAlterTable> alterTables)
        {
            //using (SqliteConnection connection = new SqliteConnection(ConnectionClass.newDatabasePath))
            //{
            //    connection.Open();
            //    using (SqliteCommand command = connection.CreateCommand())
            //    {
            //        command.CommandTimeout = 30;
            //        command.CommandText = String.Format("select s_gr_constr.c_gr_constr, is_constr, s_defect.*, item_type, lock_expert, life, ord from s_gr_constr " +
            //            "left outer join s_def4constr on s_def4constr.c_gr_constr = s_gr_constr.c_gr_constr " +
            //            "left outer join s_defect on s_defect.c_defect = s_def4constr.c_defect " +
            //            "where s_defect.c_defect is not null and s_gr_constr.c_gr_constr={0}", CGrConstr);
            //        command.CommandType = System.Data.CommandType.Text;
            //        using (SqliteDataReader dataReader = command.ExecuteReader())
            //        {
            //            if (dataReader.HasRows)
            //            {
            //                while(dataReader.Read())
            //                {
            //                    Boolean lockExpert = false;
            //                    if (dataReader["lock_expert"] != DBNull.Value) lockExpert = dataReader.GetBoolean(dataReader.GetOrdinal("lock_expert"));
            //                    DefectList.Add(new ais7DefectItem(this,
            //                        dataReader.GetInt32(dataReader.GetOrdinal("c_defect")),
            //                        dataReader.GetString(dataReader.GetOrdinal("n_defect")),
            //                        dataReader["W_DEF"] != DBNull.Value ? dataReader.GetString(dataReader.GetOrdinal("W_DEF")) : "",
            //                        lockExpert));
            //                }
            //            }
            //        }
            //    }
            //}
            var subTable = alterTables.FindAll(x => x.c_gr_constr == CGrConstr);

            foreach (var subItem in subTable)
            {
                DefectList.Add(new Ais7DefectItem(this, subItem.C_DEFECT, subItem.N_DEFECT, subItem.W_DEF, subItem.LOCK_EXPERT));
            }
        }