public object Clone() { LotteryScript clone = new LotteryScript(); clone.mLiveScript = (LiveScript)this.mLiveScript.Clone(); clone.mPrizeStr = (string)this.mPrizeStr.Clone(); //throw new NotImplementedException(); return(clone); }
/// <summary> /// 列表控件删除按钮响应函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void list_key_up(object sender, KeyEventArgs e) { if (e.KeyboardDevice.IsKeyUp(Key.Delete)) { // MessageBox.Show("删除按键弹起"); LotteryScript SelectItem = (LotteryScript)(HitPrizeList.SelectedItem as LotteryScript).Clone();; mHitPrizeList.Remove(SelectItem); //for (int i = mHitPrizeList.Count - 1; i >= 0; i--) //{ // var item = mHitPrizeList[i]; // if (item.Equals(SelectItem)) // { // mHitPrizeList.RemoveAt(i); // } //} } }
/// <summary> /// 抽奖按钮的响应函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LotteryHandle(object sender, RoutedEventArgs e) { if (prizeSet.SelectedIndex == -1) { MessageBox.Show("请选择或者添加奖品信息", "随机抽奖机"); return; } int listCount = mCountPrizeList.Count; int levelLitmit = ComboBoxLevelLimit.SelectedIndex == -1 ? 0 : ComboBoxLevelLimit.SelectedIndex; if (listCount > 0 && mLotteryManNum > mHitPrizeList.Count) { Random random = new Random(); for (int i = 0; i < listCount; i++) { int index = random.Next(listCount); bool bFind = mHitPrizeList.Any <LotteryScript>(P => P.SCRIPT.UID == mCountPrizeList[index].UID); if (bFind == false && mCountPrizeList[index].LEVEL >= levelLitmit) { LotteryScript lotteryscript = new LotteryScript(); lotteryscript.SCRIPT = (LiveScript)mCountPrizeList[index].Clone(); if (prizeSet.SelectedIndex != -1) { lotteryscript.PRIZE = prizeSet.SelectedItem.ToString(); } else { lotteryscript.PRIZE = ""; } mHitPrizeList.Add(lotteryscript); break; } } } }