public static IRoomModel Create(int roomId, int tab,string gridXml,IRuleModel rule) { return new RoomModelByDdz(roomId, rule, tab, gridXml); }
/// <summary> /// 性能优化,直接 return 就行了 /// </summary> /// <returns></returns> public static IChairModel Create(int id,IRuleModel rule) { return new ChairModelByDdz(id,rule); }
public void SwapIndicesWith(IRuleModel model) { var m = (RuleModel)model; var temp = m.Index; this.Index = m.Index; m.Index = temp; }
public ChairModelByDdz(int id, IRuleModel rule) { this._id = id; this._user = UserModelFactory.Create(); this._ready = false; this._readyAdd = ""; }
private void btnDown_Click(object sender, EventArgs e) { if (grdRules.SelectedRows.Count == 1) { int first = grdRules.SelectedRows[0].Index; int second = first + 1; IRuleModel rfirst = (IRuleModel)_rules[first]; IRuleModel rsecond = (IRuleModel)_rules[second]; _rules[first] = _rules[second]; _rules[second] = rfirst; grdRules.Rows[first].Selected = false; grdRules.Rows[second].Selected = true; rfirst.SwapIndicesWith(rsecond); ReSyncBindingListToRules(_style); } }
private void btnDuplicateRule_Click(object sender, EventArgs e) { if (grdRules.SelectedRows.Count == 1) { ILabeledRuleModel lrm = grdRules.SelectedRows[0].DataBoundItem as ILabeledRuleModel; IRuleModel rm = grdRules.SelectedRows[0].DataBoundItem as IRuleModel; //Test the labeled rule first as it can be both if (lrm != null) { Debug.Assert(_style.StyleType != StyleType.Composite); //HACK: Only Maestro knows that all impls of ILayerDefinition also implements ILayerElementFactory2 ILabeledRuleModel clone = lrm.CloneLabeledRuleModel(_editedLayer); switch (_style.StyleType) { case StyleType.Point: ((IPointVectorStyle)_style).AddRule((IPointRule)clone.UnwrapRule()); clone.SetIndex(_style.RuleCount - 1); break; case StyleType.Line: ((ILineVectorStyle)_style).AddRule((ILineRule)clone.UnwrapRule()); clone.SetIndex(_style.RuleCount - 1); break; case StyleType.Area: ((IAreaVectorStyle)_style).AddRule((IAreaRule)clone.UnwrapRule()); clone.SetIndex(_style.RuleCount - 1); break; } _rules.Add(clone); } else if (rm != null) { Debug.Assert(_style.StyleType == StyleType.Composite); //HACK: Only Maestro knows that all impls of ILayerDefinition also implements ILayerElementFactory2 IRuleModel clone = rm.CloneRuleModel(_editedLayer); ((ICompositeTypeStyle)_style).AddCompositeRule((ICompositeRule)clone.UnwrapRule()); clone.SetIndex(_style.RuleCount - 1); _rules.Add(clone); } } }
private void UpdateRulePreviewAsync(IRuleModel rule) { UpdateRulePreviewsAsync(new IRuleModel[] { rule }); }
private void ReSyncBindingListToRules(IVectorStyle style) { if (style != null) { switch (style.StyleType) { case StyleType.Point: { IPointVectorStyle pts = style as IPointVectorStyle; pts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; IPointRule pr = (IPointRule)rule.UnwrapRule(); pts.AddRule(pr); rule.SetIndex(i); } } break; case StyleType.Line: { ILineVectorStyle lts = style as ILineVectorStyle; lts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; ILineRule lr = (ILineRule)rule.UnwrapRule(); lts.AddRule(lr); rule.SetIndex(i); } } break; case StyleType.Area: { IAreaVectorStyle ats = style as IAreaVectorStyle; ats.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; IAreaRule ar = (IAreaRule)rule.UnwrapRule(); ats.AddRule(ar); rule.SetIndex(i); } } break; case StyleType.Composite: { ICompositeTypeStyle cts = style as ICompositeTypeStyle; cts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { IRuleModel rule = (IRuleModel)_rules[i]; ICompositeRule cr = (ICompositeRule)rule.UnwrapRule(); cts.AddCompositeRule(cr); rule.SetIndex(i); } } break; } } }
public static IRoomModel Create(int roomId, int tab, string gridXml, IRuleModel rule) { return(new RoomModelByDdz(roomId, rule, tab, gridXml)); }
public static IRoomModel Create(int roomId, int tab, IRuleModel rule) { return(new RoomModelByDdz(roomId, rule, tab, "")); }
void given_scenario_to_match_rule() { _scenarioToMatchRule = MockRepository.GenerateStub <IRuleModel>(); _scenarioToMatchRule.Stub(x => x.GetRuleXml()).Return("Pick Me"); }
public static IRoomModel Create(int roomId, int tab, IRuleModel rule) { return new RoomModelByDdz(roomId,rule,tab,""); }
/// <summary> /// 性能优化,直接 return 就行了 /// </summary> /// <returns></returns> public static IChairModel Create(int id, IRuleModel rule) { return(new ChairModelByDdz(id, rule)); }
public RoomModelByDdz(int id, IRuleModel rule, int tab, string gridXml) { this._id = id; this._tab = tab; if ("" == gridXml) { this._name = string.Empty; } else { XmlDocument gridDoc = new XmlDocument(); gridDoc.LoadXml(gridXml); this._name = gridDoc.DocumentElement.Attributes["name"].Value; } this.setStatus(RoomStatusByDdz.GAME_WAIT_START); this._matchResult = MATCH_RESULT.EMPTY; this._chair = new List<IChairModel>(); for (int i = 1; i <= rule.getChairCount(); i++) { this._chair.Add(ChairModelFactory.Create(i, rule)); }//end for //red = ""; //black = ""; this.difen = ""; this.bomb = 0; this.leaveBomb = 0; this.leaveUserId = ""; this.dizhu = ""; this.nongming = ""; this.mingpai = ""; this.turn = ""; this._board = new PaiBoardByDdz(); this._record = new RoundModelByDdz(ROUND_TYPE.JIAO_FEN); this._round = new List<RoundModelByDdz>(); _runAwayMultiG = 1; _isWaitReconnection = false; _curWaitReconnectionTime = 0; _waitReconnectionUser = null; }