//由外部调用,创建整个赛事模型,利用向导对话框 //如果返回的无数据,标识创建失败 public static AxDrawModelEvent CreateModelEvent() { AxDrawModelEvent modelEvent = new AxDrawModelEvent(); DialogResult drResult; AxModelWizardFrameForm fmModelEditForm = new AxModelWizardFrameForm(); fmModelEditForm.ShowDialog(); drResult = fmModelEditForm.DialogResult; if (drResult != DialogResult.OK) { return(modelEvent); } modelEvent = fmModelEditForm.m_ModelEvent; //把所有比赛实际创建出来 for (Int32 nStage = 0; nStage < modelEvent.GetStageCnt(); nStage++) { AxDrawModelStage pModelStage = modelEvent.GetStageObj(nStage); for (Int32 nModel = 0; nModel < pModelStage.GetModelCnt(); nModel++) { AxDrawModelModelExport pModelExport = pModelStage.GetModelExpObj(nModel); pModelExport.m_matchList = _CreateModelSingle(pModelExport.m_drawInfo); } } modelEvent.CreateMatchNum(); return(modelEvent); }
//将整个Event中所有比赛编号,按照Event的轮为单位 public Boolean CreateMatchNum() { Int32 dwMatchNum = 1; //从1开始 for (Int32 nStage = 0; nStage < GetStageCnt(); nStage++) { AxDrawModelStage pStage = GetStageObj(nStage); ArrayList aryDwCurMatchIdxInModel = new ArrayList(); //目前Stage中每个Model进行到第几场比赛了,用来在循环中作记忆 //把个数设为Model个数,并且每个都是先从第一个开始 for (Int32 nCyc = 0; nCyc < pStage.GetModelCnt(); nCyc++) { aryDwCurMatchIdxInModel.Add(0); } do//填序号,直到每个Model的所有比赛都填了序号 { //循环每个Model,进行排号,每个Model有一次机会时,把这轮所有的号拍完, //之后释放机会,等下次机会再排下一轮 for (Int32 nModel = 0; nModel < pStage.GetModelCnt(); nModel++) { AxDrawModelModelExport pModel = pStage.GetModelExpObj(nModel); //获取阶段中当前模型排号到哪场比赛了 Int32 dwCurMatchIdxInModel = (Int32)aryDwCurMatchIdxInModel[nModel]; if (dwCurMatchIdxInModel < 0 || dwCurMatchIdxInModel > pModel.GetMatchCnt()) { Debug.Assert(false); return(false); } if (dwCurMatchIdxInModel >= pModel.GetMatchCnt()) { //如果存的标志大于本Model比赛个数,说明此Model比赛都添加过了 continue; } AxDrawModelMatchRow pMatch = pModel.GetMatchObj(dwCurMatchIdxInModel); //得到当前的比赛 Int32 byCurRound = Convert.ToInt32(pMatch.m_byteRoundOrder); pMatch.m_dwMatchNum = Convert.ToUInt32(dwMatchNum++); dwCurMatchIdxInModel++; while (dwCurMatchIdxInModel < pModel.GetMatchCnt() && Convert.ToUInt32(pModel.GetMatchObj(dwCurMatchIdxInModel).m_byteRoundOrder) == byCurRound) { pModel.GetMatchObj(dwCurMatchIdxInModel).m_dwMatchNum = Convert.ToUInt32(dwMatchNum++); dwCurMatchIdxInModel++; } aryDwCurMatchIdxInModel[nModel] = dwCurMatchIdxInModel; //把此Model下次该进行场次排号的Index写入记忆数组 } //查找是否还有需要填写的 Boolean bNeedFill = false; for (Int32 nCycModel = 0; nCycModel < pStage.GetModelCnt(); nCycModel++) { Int32 dwCurMatchIdx = (Int32)aryDwCurMatchIdxInModel[nCycModel]; if (dwCurMatchIdx < pStage.GetModelExpObj(nCycModel).GetMatchCnt()) { bNeedFill = true; break; } } if (!bNeedFill) { break; //此Stage填数完成,进入下一个Stage } }while (true); }//for Stage return(true); }