private void validateMyself() { if (Validation.GetHasError(CollectionBoxValue)) { RangeRule rr = new RangeRule(); ValidationResult vr = rr.Validate(CollectionBoxValue.Text, new CultureInfo("en-US", false)); PrizeLevelConverter plc = new PrizeLevelConverter(); if (vr.Equals(new ValidationResult(false, "Illegal characters"))) { ucplID = ErrorService.Instance.reportError("005", new List <string> { (string)plc.Convert(plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")) }, ucplID); } else if (vr.Equals(new ValidationResult(false, "Please enter a number in the given range."))) { ucplID = ErrorService.Instance.reportError("006", new List <string> { (string)plc.Convert(plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")), "0", "20" }, ucplID); } else if (vr.Equals(new ValidationResult(false, "Cannot be nothing"))) { ucplID = ErrorService.Instance.reportError("008", new List <string> { (string)plc.Convert(plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")) }, ucplID); } } else { ErrorService.Instance.resolveError("005", null, ucplID); ErrorService.Instance.resolveError("006", null, ucplID); ErrorService.Instance.resolveError("008", null, ucplID); } shout("Update"); }
public void Test_Invalid_Convert() { PrizeLevelConverter plc = new PrizeLevelConverter(); Assert.IsTrue(((string)plc.Convert(null, typeof(string), null, new System.Globalization.CultureInfo("en-us"))).Equals("")); }
public void onListen(object pass) { if (pass is string) { String parse = (String)pass; if (parse.Equals("Update")) { List <UserControlPrizeLevel> ucplList = new List <UserControlPrizeLevel>(); ucplList = Prizes.Children.Cast <UserControlPrizeLevel>().ToList <UserControlPrizeLevel>(); Prizes.Children.Clear(); ucplList.Sort(); plsObject.sortPrizeLevels(); int collectionToShout = 0; int index = 0; bool sameFound = false; PrizeLevelConverter plc = new PrizeLevelConverter(); for (int i = 0; i < ucplList.Count; i++) { ucplList[i].LevelGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ADADAD")); // fff000 ucplList[i].OuterGrid.Margin = new Thickness(0, i * MARGIN, 0, 0); ucplList[i].plObject.prizeLevel = (i + 1); if (ucplList[i].plObject.numCollections > collectionToShout) { collectionToShout = ucplList[i].plObject.numCollections; index = i; } Prizes.Children.Add(ucplList[i]); //This searches for prize levels that are the same if (i != (ucplList.Count - 1)) { for (int j = i + 1; j < ucplList.Count; j++) { if (((ucplList[i].plObject.isInstantWin && ucplList[j].plObject.isInstantWin) || (!ucplList[i].plObject.isInstantWin && !ucplList[j].plObject.isInstantWin)) && (ucplList[i].plObject.numCollections == ucplList[j].plObject.numCollections) && (ucplList[i].plObject.prizeValue == ucplList[j].plObject.prizeValue)) { plsID = ErrorService.Instance.reportWarning("004", new List <string> { (string)plc.Convert(ucplList[i].plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")), (string)plc.Convert(ucplList[j].plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")) }, plsID); sameFound = true; } } } } if (!sameFound) { ErrorService.Instance.resolveWarning("004", null, plsID); } if (collectionCheck < collectionToShout) { plsID = ErrorService.Instance.reportError("004", new List <string> { (string)plc.Convert(ucplList[index].plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")), collectionCheck.ToString() }, plsID); } else if (collectionCheck >= collectionToShout) { ErrorService.Instance.resolveError("004", new List <string> { (string)plc.Convert(ucplList[index].plObject.prizeLevel, typeof(string), null, new System.Globalization.CultureInfo("en-us")), collectionCheck.ToString() }, plsID); } } } else if (pass is UserControlPrizeLevel) { //This removes the PrizeLevel that was just closed if (plsObject.getNumPrizeLevels() > 2) { UserControlPrizeLevel rem = (UserControlPrizeLevel)pass; int index = -1; for (int i = 0; i < Prizes.Children.Count && index < 0; i++) { UserControlPrizeLevel ucpl = (UserControlPrizeLevel)Prizes.Children[i]; if (ucpl == rem) { index = i; } } rem.plObject = null; Prizes.Children.Remove(rem); plsObject.removePrizeLevel(index); rem = null; for (int i = 0; i < Prizes.Children.Count; i++) { UserControlPrizeLevel ucpl = (UserControlPrizeLevel)Prizes.Children[i]; ucpl.LevelGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ADADAD")); ucpl.OuterGrid.Margin = new Thickness(0, i * MARGIN, 0, 0); ucpl.plObject.prizeLevel = (i + 1); if (plsObject.getNumPrizeLevels() == 2) { ucpl.CloseButton.IsEnabled = false; ucpl.CloseButton.Opacity = 0.0f; } else { ucpl.CloseButton.IsEnabled = true; ucpl.CloseButton.Opacity = 1; } } AddButton.IsEnabled = true; AddButton.Opacity = 1; } } //Shouts PrizeLevels object so divisions can analyze it shout(plsObject); prizeLevelCounterLabel.Content = Prizes.Children.Count; }