Beispiel #1
0
 /// <summary>
 /// 绑定附属部队
 /// </summary>
 /// <param name="oobInfo"></param>
 /// <param name="acNum"></param>
 private void ShowUserControl(OOBInfo oobInfo)
 {
     try
     {
         AttachmentControl ac = new AttachmentControl(oobInfo, localisationModel, pathInfo, countryCode, militaryTypeList);
         ac.Parent = this.panel1;
         int pointy = acNum == 0 ? (acNum * 105) : (acNum * 105);
         ac.Location = new Point(5, pointy);
         ac.Height   = 100;
         this.panel1.Controls.Add(ac);
     }
     catch (Exception ex)
     {
         ShowErrorMessage("附属部队绑定失败:" + ex.Message);
     }
 }
Beispiel #2
0
        private void Save(object sender, EventArgs e)
        {
            try
            {
                int ID = Convert.ToInt32(txt_BasicID.Text);

                OOBInfo oobUpdateInfo = oobList.Find(o => o.id == ID);
                //移除当前的oob
                //oobList.Remove(oobUpdateInfo);

                #region 赋值基本信息
                if (!string.IsNullOrEmpty(txt_BasicName.Text))
                {
                    oobUpdateInfo.name = txt_BasicName.Text;
                    this.tv_Military.SelectedNode.Text = txt_BasicName.Text;
                }
                if (!string.IsNullOrEmpty(txt_BasicLocation.Text))
                {
                    Regex           reg = new Regex(@"[0-9][0-9,.]*");
                    MatchCollection mc  = reg.Matches(txt_BasicLocation.Text);
                    if (mc.Count > 0)
                    {
                        if (oobUpdateInfo.armyType != ArmyTypeEnum.Navy && oobUpdateInfo.armyType != ArmyTypeEnum.Air)
                        {
                            oobUpdateInfo.location = mc[0].Value;
                        }
                        else
                        {
                            oobUpdateInfo.location = mc[0].Value;
                            oobUpdateInfo.baseID   = mc[0].Value;
                        }
                    }
                }
                if (cb_Reserve.Enabled && oobUpdateInfo.armyType == ArmyTypeEnum.Division)
                {
                    oobUpdateInfo.is_reserve = cb_Reserve.Checked;
                }
                if (!string.IsNullOrEmpty(txt_LeaderID.Text))
                {
                    oobUpdateInfo.leader = txt_LeaderID.Text.Trim();
                }
                //oobList.Add(oobUpdateInfo);
                #endregion

                #region 赋值附属部队的信息
                int currentAcNum = oobList.FindAll(att => att.parentID == ID &&
                                                   (att.armyType == ArmyTypeEnum.Regiment || att.armyType == ArmyTypeEnum.Ship || att.armyType == ArmyTypeEnum.Wing)).Count;
                int num = 0;
                foreach (Control c in this.panel1.Controls)
                {
                    if (num < currentAcNum)
                    {
                        AttachmentControl ac        = (AttachmentControl)c;
                        TextBox           txt_AttID = (TextBox)ac.Controls[0].Controls.Find("txt_AttID", false)[0];
                        int     attID            = Convert.ToInt32(txt_AttID.Text);
                        OOBInfo oobAttUpdateInfo = oobList.Find(o => o.id == attID);
                        //oobList.Remove(oobAttUpdateInfo);

                        TextBox txt_AttName = (TextBox)ac.Controls[0].Controls.Find("txt_AttName", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttName.Text))
                        {
                            oobAttUpdateInfo.name = txt_AttName.Text;
                        }
                        TextBox txt_AttExp = (TextBox)ac.Controls[0].Controls.Find("txt_AttExp", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttExp.Text))
                        {
                            oobAttUpdateInfo.experience = txt_AttExp.Text;
                        }
                        ComboBox cbb_AttType = (ComboBox)ac.Controls[0].Controls.Find("cbb_AttType", false)[0];
                        if (cbb_AttType.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            oobAttUpdateInfo.type = militaryTypeInfo.type;
                        }
                        ComboBox cbb_AttModel = (ComboBox)ac.Controls[0].Controls.Find("cbb_AttModel", false)[0];
                        if (cbb_AttModel.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            if (militaryTypeInfo.unitModelList != null || militaryTypeInfo.unitModelList.Count > 0)
                            {
                                oobAttUpdateInfo.historical_model = militaryTypeInfo.unitModelList.Find(uml => uml.name == cbb_AttModel.SelectedItem.ToString()).modelNum;
                            }
                        }
                        //oobList.Add(oobAttUpdateInfo);
                    }
                    else
                    {
                        Add_AttachmentControl aac = (Add_AttachmentControl)c;
                        TextBox txt_AttID         = (TextBox)aac.Controls[0].Controls.Find("txt_AttID", false)[0];
                        int     attID             = Convert.ToInt32(txt_AttID.Text);
                        OOBInfo oobAttAddInfo     = new OOBInfo();
                        oobAttAddInfo.id       = attID;
                        oobAttAddInfo.parentID = ID;
                        TextBox txt_AttName = (TextBox)aac.Controls[0].Controls.Find("txt_AttName", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttName.Text))
                        {
                            oobAttAddInfo.name = txt_AttName.Text;
                        }
                        TextBox txt_AttExp = (TextBox)aac.Controls[0].Controls.Find("txt_AttExp", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttExp.Text))
                        {
                            oobAttAddInfo.experience = txt_AttExp.Text;
                        }
                        ComboBox cbb_AttType = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttType", false)[0];
                        if (cbb_AttType.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            oobAttAddInfo.type = militaryTypeInfo.type;
                        }
                        ComboBox cbb_AttModel = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttModel", false)[0];
                        if (cbb_AttModel.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            if (militaryTypeInfo.unitModelList != null || militaryTypeInfo.unitModelList.Count > 0)
                            {
                                oobAttAddInfo.historical_model = militaryTypeInfo.unitModelList.Find(uml => uml.name == cbb_AttModel.SelectedItem.ToString()).modelNum;
                            }
                        }
                        if (oobUpdateInfo.armyType == ArmyTypeEnum.Navy)
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Ship;
                        }
                        else if (oobUpdateInfo.armyType == ArmyTypeEnum.Air)
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Wing;
                        }
                        else
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Regiment;
                        }
                        oobList.Add(oobAttAddInfo);
                    }
                    num++;
                }
                #endregion

                //this.tv_Military.Nodes.Clear();
                BindTree(0, oobList);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("保存失败:" + ex.Message);
            }
        }