public void AddWordAndDefinition() { if (Count >= maxCount) { return; } var wd = new WordAndDefinition(); wd.Index.Text = (Count + 1).ToString(); wd.CloseButton.Click += (sender, e) => { if (WordsStackPanel.Children.Count <= 1) { return; } WordsStackPanel.Children.Remove(wd); for (var i = 0; i < Count; ++i) { (WordsStackPanel.Children[i] as WordAndDefinition).Index.Text = (i + 1).ToString(); } CountChange?.Invoke(this, EventArgs.Empty); }; WordsStackPanel.Children.Add(wd); CountChange?.Invoke(this, EventArgs.Empty); }
public void CountChangePossibilitiesShouldReturn4() { int money = 10; int[] coins = { 5, 3, 2 }; Assert.Equal(4, CountChange.CountChangePossibilities(money, coins)); }
public void CountChangePossibilitiesShouldReturn3() { int money = 4; int[] coins = { 1, 2 }; Assert.Equal(3, CountChange.CountChangePossibilities(money, coins)); }
public void Resize(int wordsAmount) { if (wordsAmount < Count) { WordsStackPanel.Children.RemoveRange(wordsAmount, Count - wordsAmount); } else { for (var i = 0; Count < wordsAmount; ++i) { AddWordAndDefinition(); } } CountChange?.Invoke(this, EventArgs.Empty); }
// PUT api/Sections/{id}/Update public HttpResponseMessage UpdateSection(int id, [FromBody] CountChange tableCountChange) { using (var context = new AngularReduxDemoEntities()) { var response = new HttpResponseMessage(HttpStatusCode.OK); try { var section = context.Sections.FirstOrDefault(x => x.Id == id); section.TableCount += Convert.ToInt32(tableCountChange.change); context.SaveChanges(); return(response); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } } }
internal virtual void OnCountChange(CountChangeEventArgs e) { if (null != CountChange) { foreach (CountChangeEventHandler CountChangeHandler in CountChange.GetInvocationList()) { ISynchronizeInvoke syncInvoke = CountChangeHandler.Target as ISynchronizeInvoke; if ((null != syncInvoke) && (syncInvoke.InvokeRequired)) { try { syncInvoke.Invoke(CountChangeHandler, new object[] { this, e }); } catch { } } else { CountChangeHandler(this, e); } } } }
protected virtual void OnCountChange(int obj) { CountChange?.Invoke(obj); }