/// <summary> /// create equid /// </summary> /// <param name="equtypeid"></param> /// <returns></returns> public static string CreateEquId(MyObject.ObjectType equtypeid) { if (!NameDic.ContainsKey(equtypeid.ToString())) { NameDic.Add(equtypeid.ToString(), 0); } return(equtypeid + "_" + (++NameDic[equtypeid.ToString()]).ToString("0000")); }
/// <summary> /// 双击,没有选中双击批量生成设备 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void context_DoubleClicked(object sender, EventArgs e) { try { if (this.panel1.m_pCurrentObject == null) { #region create object createAddDialog.StartPosition = FormStartPosition.CenterParent; if (createAddDialog.ShowDialog(this) == DialogResult.OK) { MyObject.ObjectType obj = (MyObject.ObjectType)createAddDialog.cb_equtype.SelectedValue; int count = (int)createAddDialog.nd_equNum.Value;//需要生成对象的数量 int startNum = 1; int.TryParse(createAddDialog.tb_startNum.Text, out startNum); int cfgNum = 0; try { cfgNum = int.Parse(createAddDialog.tb_cfgnum.Text); } catch (Exception) { Log.WriteLog("配置号码格式不正确"); createAddDialog.Hide(); } DBOPs db = new DBOPs(); int parentWith = this.panel1.BackgroundImage.Size.Width; for (int i = 0; i < count; i++) { var lacation = ((MouseEventArgs)e).Location; int x = (int)(parentWith - 2 * lacation.X) / (count - 1) * i + lacation.X; lacation = new System.Drawing.Point { X = x, Y = lacation.Y }; MyObject myObject = panel1.DrawObject(obj.ToString(), lacation); if (createAddDialog.checkbox_way.Checked) { myObject.equ.EquName = createAddDialog.tb_nameFirst.Text + (startNum++); } else { myObject.equ.EquName = createAddDialog.tb_nameFirst.Text + (startNum--); } if (obj == MyObject.ObjectType.EP_T) { ep_c_cfg ep = new ep_c_cfg(); ep.EquID = myObject.equ.EquID; ep.Mesg = myObject.equ.EquName; if (createAddDialog.checkbox_way.Checked) { ep.EPNum = (cfgNum++).ToString();; } else { ep.EPNum = (cfgNum--).ToString(); } db.InsertEp(ep); } else if (obj == MyObject.ObjectType.F_L || obj == MyObject.ObjectType.F_SB || obj == MyObject.ObjectType.F_YG) { } } } #endregion } else { SetObjectPro(); } } catch (Exception ex) { Log.WriteLog(ex); } }