public ClockView(ClockViewModel vm) { _vm = vm; _vm.PropertyChanged += (sender, args) => OnTimerTick(_vm.Hour, vm.Minute); AbsoluteLayout absoluteLayout = new AbsoluteLayout(); // Create the tick marks (to be sized and positioned later) for (int i = 0; i < tickMarks.Length; i++) { tickMarks[i] = new BoxView { Color = Color.Accent }; absoluteLayout.Children.Add(tickMarks[i]); } // Create the three hands. absoluteLayout.Children.Add(hourHand = new BoxView { Color = Color.Accent }); absoluteLayout.Children.Add(minuteHand = new BoxView { Color = Color.Accent }); absoluteLayout.Children.Add(secondHand = new BoxView { Color = Color.Accent }); Content = absoluteLayout; // Attach a couple event handlers. //Device.StartTimer(TimeSpan.FromMilliseconds(16), OnTimerTick); OnTimerTick(10,15); }
public TimeTranslatePage() { NavigationPage.SetHasNavigationBar(this, false); vm = new ClockViewModel(); TimePicker.SelectedIndex = 0; vm.AM = true; BackgroundColor = Colors.SoftGray; Title = "Översättning"; Icon = "128/resizedimagelanguage.png"; TimePicker.SelectedIndexChanged += (sender, args) => { if (TimePicker.SelectedIndex == 0) { vm.AM = true; } else if (TimePicker.SelectedIndex == 1) { vm.AM = false; } }; TimePicker.Unfocused += (sender, args) => { OKClickedCommand.Execute(null); }; Padding = new Thickness(0, 20, 0, 0); //var clockView = new ClockView(vm) //{ // MinimumHeightRequest = 100, // MinimumWidthRequest = 100 //}; //SizeChanged += clockView.OnPageSizeChanged; TimeEntry.TextChanged += (sender, args) => { if (TimeEntry.Text.Length > 0) { CalculateButton.IsEnabled = true; } }; Content = new ContentView { Content = new StackLayout { Children = { TimeEnterStackLayout, TotalTimeStackLayout, }, Orientation = StackOrientation.Vertical, Spacing = 10, VerticalOptions = LayoutOptions.CenterAndExpand } }; }