/// <summary> </summary> /// <param name="invoiceAdd">this is a test</param> /// <returns></returns> /// <remarks> /// /// /// </remarks> public async Task <ICounterView> CounterAdd(ICounterAdd counterAdd) { try { var result = new CounterView(); using (var db = new InvoiceContext()) { var counter = new Database.Counter(); db.Counters.Add(counter); counter.Name = counterAdd.Name; counter.Value = counterAdd.Value; //UserCodeBlockStart-PreSave //UserCodeBlockEnd-PreSave await db.SaveChangesAsync(); result.Name = counter.Name; result.Value = counter.Value; //UserCodeBlockStart-PreResult //UserCodeBlockEnd-PreResult return(result); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new CounterView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create CounterView", __CQRSStatusCode = 500 }); } }
public CounterView PrepareCountersData() { var data = _newsService.GetNewsItem(new FilterNewsItemParameters()); var model = new CounterView { WeekDate = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + 1), TodayDate = DateTime.Today, ThreeDayDate = DateTime.Today.AddDays(-2), TodayCount = _newsService.GetNewsItem(TodayFilter())?.Count() ?? 0, //сегодня PrevDayCount = _newsService.GetNewsItem(DayBeforeFilter())?.Count() ?? 0, //вчера WeekCount = _newsService.GetNewsItem(CurWeekFilter())?.Count() ?? 0, //тек. неледя PrevWeekCount = _newsService.GetNewsItem(PrevWeekFilter())?.Count() ?? 0, //-неделя CurrentMonthCount = _newsService.GetNewsItem(CurrentMonthFilter())?.Count() ?? 0, //тек. месяц PrevMonthCount = _newsService.GetNewsItem(PrevMonthFilter())?.Count() ?? 0, //-месяц TotalCount = _newsService.GetNewsItem(TotalFilter())?.Count() ?? 0, //ИТОГО }; return(model); }
public CounterView PrepareCountersData() { var data = _counterRepository.GetAll; var threeDay = data.Where(c => c.LastDate > DateTime.Now.Date.AddDays(-3)); var model = new CounterView { TodayCount = CountersService.TodayUniqueUsers(), TotalCount = CountersService.TotalUniqueUsers(), PrevDayCount = data.FirstOrDefault(c => c.LastDate > DateTime.Now.Date.AddDays(-1)).TodayCount, WeekCount = CurWeekCount(data), ThreeDayCount = threeDay.Sum(c => c.TodayCount), WeekDate = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + 1), TodayDate = DateTime.Today, ThreeDayDate = DateTime.Today.AddDays(-2), PrevWeekCount = PrevWeekCount(data), CurrentMonthCount = CurrentMonthCount(data), PrevMonthCount = PrevMonthCount(data) }; return(model); }
/// <summary> </summary> /// <param name="invoiceAdd">this is a test</param> /// <returns></returns> /// <remarks> /// /// /// </remarks> public async Task <ICounterView> CounterUpdate(ICounterUpdate counterUpdate) { try { var result = new CounterView(); using (var db = new InvoiceContext()) { if (db.Counters.Any(w => w.Name == counterUpdate.Name)) { var counter = db.Counters.First(w => w.Name == counterUpdate.Name); counter.Value = counterUpdate.Value; await db.SaveChangesAsync(); result.Name = counter.Name; result.Value = counter.Value; return(result); } } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new CounterView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create CounterView", __CQRSStatusCode = 500 }); } return(null); }
public async Task <ICounterView> GetCounter(IGetCounter getCounter) { try { var result = new CounterView(); using (var db = new InvoiceContext()) { if (await db.Counters.AnyAsync(w => w.Name == getCounter.Name)) { var counter = await db.Counters.FirstAsync(w => w.Name == getCounter.Name); result.Name = counter.Name; result.Value = counter.Value; return(result); } else { return(new CounterView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to find item", __CQRSStatusCode = 500 }); } } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new CounterView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create CounterView", __CQRSStatusCode = 500 }); } }
public GamePresenter( GameModel model, DiggableFieldView gameField, CounterView shovelConter, CounterView diamondCounter, BackpackView backpack ) { shovelConter.SetCount(model.ShovelCount); gameField.OnGroundTouch += fieldCell => { if (model.CanDig(fieldCell.Position)) { gameField.Dig(fieldCell.Position); if (model.TryDigDiamond(fieldCell.Position)) { gameField.PlaceDiamond(fieldCell.Position); } } }; backpack.OnItemGrabed += position => model.CollectDiamond(position); model.OnShavelCountChanged += count => shovelConter.SetCount(count); model.OnDiamondCountChanged += count => diamondCounter.SetCount(count); }
private static CounterView AddCounterView(UIView parent) { var counterView = new CounterView(); parent.AddSubview(counterView); return(counterView); }
public ListViewSpy() { __listViewSpyAlloc++; var name = GetType().Name; var hasUnevenRows = name.Contains("UnevenRows"); var isGrouped = name.Contains("Grouped"); _itemsList = isGrouped ? (IItemList) new LazyGroupedItemList(GroupCount, ItemsCount) : new LazyItemList(ItemsCount); var strategy = name.Contains("RecycleElementAndDataTemplate") ? ListViewCachingStrategy.RecycleElementAndDataTemplate : name.Contains("RecycleElement") ? ListViewCachingStrategy.RecycleElement : ListViewCachingStrategy.RetainElement; var dataTemplate = strategy == ListViewCachingStrategy.RecycleElement ? new Selector.SelectByData() : strategy == ListViewCachingStrategy.RecycleElementAndDataTemplate ? new Selector.SelectByType() : new DataTemplate(typeof(ItemViewCell.Constant)); _listView = new ListView(strategy) { HasUnevenRows = hasUnevenRows, // see https://github.com/xamarin/Xamarin.Forms/pull/994/files //RowHeight = 50, ItemsSource = _itemsList, ItemTemplate = dataTemplate, IsGroupingEnabled = isGrouped, GroupDisplayBinding = null, GroupShortNameBinding = null, GroupHeaderTemplate = null }; Children.Add(_listView); _listView.AutomationId = $"__ListView"; var counter = new CounterView(); _listView.ItemAppearing += (o, e) => { _appeared = (e.Item as Item)?.Id ?? -1; counter.Update(); }; _listView.ItemDisappearing += (o, e) => { _disappeared = (e.Item as Item)?.Id ?? -1; counter.Update(); }; Children.Add(counter); }
private void CounterTapped(object sender, EventArgs e) { ChangeColor(sender); SearchIcon.IsVisible = false; CounterView.IsVisible = true; AzkarView.IsVisible = false; QiblaView.IsVisible = false; Action <double> callback = input => CounterView.TranslationX = input; CounterView.Animate("anim", callback, 300, 0, 16, 300, Easing.CubicInOut); }
private void AddViews() { _initiatingLabel = this.AddLabel("", 20, UIColor.White); _counterLabel = this.AddLabel("", 40, UIColor.White); _watch = UIImage.FromBundle("Watch"); _watchImageView = AddImageView(this, _watch); _counterView = AddCounterView(this); _row1Cursor = AddBlinkySquareView(this); _row2Cursor = AddBlinkySquareView(this); _codeStringsScene = AddCodeStringsView(this); }
public async Task <ICounterView> CounterNext(ICounterNext counterNext) { try { var result = new CounterView(); using (var db = new InvoiceContext()) { if (db.Counters.Any(w => w.Name == counterNext.Name)) { var counter = db.Counters.First(w => w.Name == counterNext.Name); counter.Name = counterNext.Name; //UserCodeBlockStart-1 counter.Value = counter.Value + 1; //UserCodeBlockEnd-1 await db.SaveChangesAsync(); result.Name = counter.Name; result.Value = counter.Value; return(result); } else { var newCounter = new Database.Counter(); db.Counters.Add(newCounter); newCounter.Name = counterNext.Name; newCounter.Value = 1; await db.SaveChangesAsync(); result.Name = newCounter.Name; result.Value = newCounter.Value; return(result); } } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new CounterView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create CounterView", __CQRSStatusCode = 500 }); } return(null); }
private void bSelectCardCounter_Click(object sender, EventArgs e) { if (cbCardDetailCounters.Items.Count == 0) { return; } CounterView cv = (CounterView)cbCardDetailCounters.SelectedItem; if (cv == null) { return; } if (ContextMap.ContainsKey(cv.ID)) { ContextMap[cv.ID].Show(MousePosition); } }
/// <summary> /// RingPage UI for Timer /// title label, Hour/Minute/Second labels /// </summary> private void CreateRingLabels() { Label titleLabel = new Label { Text = "Time is up", Style = TimerStyle.ATO019, HeightRequest = 58, WidthRequest = 400, //BackgroundColor = Color.Orange, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(titleLabel, FontWeight.Light); rLayout.Children.Add(titleLabel, Constraint.RelativeToParent((parent) => { return(160); }), Constraint.RelativeToParent((parent) => { return(241 - 58); })); // case: display H/M/S hLabel = new Label { Text = "Hours", Style = TimerStyle.ATO009, IsVisible = false, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(hLabel, FontWeight.Normal); rLayout.Children.Add(hLabel, Constraint.RelativeToParent((parent) => { return(50 + 18); }), Constraint.RelativeToParent((parent) => { return(241 + 157); })); mLabel = new Label { Text = "Minutes", Style = TimerStyle.ATO009, IsVisible = false, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(mLabel, FontWeight.Normal); rLayout.Children.Add(mLabel, Constraint.RelativeToParent((parent) => { return(360 - 70); }), Constraint.RelativeToParent((parent) => { return(241 + 157); })); sLabel = new Label { Text = "Seconds", Style = TimerStyle.ATO009, IsVisible = false, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(sLabel, FontWeight.Normal); rLayout.Children.Add(sLabel, Constraint.RelativeToParent((parent) => { return(720 - 50 - 18 - 140); }), Constraint.RelativeToParent((parent) => { return(241 + 157); })); //case: display M/S _mLabel = new Label { Text = "Minutes", Style = TimerStyle.ATO009, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(_mLabel, FontWeight.Normal); rLayout.Children.Add(_mLabel, Constraint.RelativeToParent((parent) => { return(360 - 120 - 50); }), Constraint.RelativeToParent((parent) => { return(241 + 157); })); _sLabel = new Label { Text = "Seconds", Style = TimerStyle.ATO009, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(_sLabel, FontWeight.Normal); rLayout.Children.Add(_sLabel, Constraint.RelativeToParent((parent) => { return(360 + 50); }), Constraint.RelativeToParent((parent) => { return(241 + 157); })); counterview = new CounterView(CounterType.COUNTER_TYPE_TIMER); counterLayout = counterview.GetCounterLayout(); //counterLayout.BackgroundColor = Color.Lime; counterview.DisplayTime("00:00"); rLayout.Children.Add(counterLayout, Constraint.RelativeToParent((parent) => { return(50); }), Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); })); minusImage = new Image { Source = "timer/timer_ringing_minus.png", WidthRequest = 36, HeightRequest = 204, VerticalOptions = LayoutOptions.Center, //BackgroundColor = Color.FromHex("#FFFAFAFA"), IsVisible = false, }; rLayout.Children.Add(minusImage, Constraint.RelativeToParent((parent) => { return(50 - 36); }), Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); })); _minusImage = new Image { Source = "timer/timer_ringing_minus.png", WidthRequest = 36, HeightRequest = 204, VerticalOptions = LayoutOptions.Center, //BackgroundColor = Color.FromHex("FFFAFAFA"), }; rLayout.Children.Add(_minusImage, Constraint.RelativeToParent((parent) => { return(360 - 120 - 50 - 18 - 8 - 36); }), Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); })); }
/// <summary> /// Create the stopwatch main page. /// </summary> /// <returns> The StackLayout. </returns> private StackLayout CreateStopWatchPage() { if (mainView == null) { counterview = new CounterView(CounterType.COUNTER_TYPE_STOPWATCH); rLayout = counterview.GetCounterLayout(); listItems = new LapListObservableCollection(); // Create the start button startButton = new Button { Style = CommonStyle.oneButtonStyle, Text = "Start", }; VisualAttributes.SetThemeStyle(startButton, "bottom"); startButton.Clicked += StartButton_Clicked; // Create the stop button stopButton = new Button { Style = CommonStyle.twoButtonStyle, Text = "Stop", IsVisible = false, }; VisualAttributes.SetThemeStyle(stopButton, "bottom"); stopButton.Clicked += StopButton_Clicked; // Create the lap button lapButton = new Button { Style = CommonStyle.twoButtonStyle, Text = "Lap", IsVisible = false, }; VisualAttributes.SetThemeStyle(lapButton, "bottom"); lapButton.Clicked += LapButton_Clicked; // Create the layout to place start button StackLayout bsLayout = new StackLayout { HeightRequest = 150, Spacing = 0, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.End, BackgroundColor = Color.White, Children = { startButton, stopButton, lapButton } }; // Create the main view mainView = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 0, //BackgroundColor = Color.Red, Children = { rLayout, bsLayout } }; } return(mainView); }