Example #1
0
        public ClockPage()
        {
            ClockViewModel cm = new ClockViewModel();

            BindingContext = cm;
            InitializeComponent();
        }
        private void App_Startup(object sender, StartupEventArgs e)
        {
            var clockView      = new ClockView();
            var clockViewModel = new ClockViewModel();

            clockView.DataContext = clockViewModel;
            clockView.Show();
        }
Example #3
0
 public void InitializeTest()
 {
     ExecuteOnUIThread(() =>
     {
         mockGameViewModel = new MockGameViewModel();
         clockViewModel    = new ClockViewModel(mockGameViewModel);
     });
 }
 private void InitClock()
 {
     CurrentTime         = new ClockViewModel();
     Clock               = new ClockModel(CurrentTime, SmartMirror);
     clockTimer.Interval = TimeSpan.FromMilliseconds(ClockRefreshRate);
     clockTimer.Tick    += ClockTick;
     clockTimer.Start();
 }
        public ClockComponent(ClockViewModel viewModel)
        {
            ViewModel = viewModel;
            Renderer  = new Win10TaskbarClockRenderer(viewModel);

            // request this component to be redrawn , when the current time changes
            ViewModel.PropertyChanged += (s, e) => OnRefreshRequested();
        }
Example #6
0
        private static void ParseClocks(XmlNode clocksNode, Configuration config, Configuration oldConfig)
        {
            Log.TraceEntry();

            var interval = int.Parse(clocksNode.Attr(DisplayIntervalInSecondsAttribute));

            var clocks = new List <ClockViewModel>();

            foreach (XmlNode node in clocksNode.ChildNodes)
            {
                if (!CheckRolesForInclusion(node, config))
                {
                    continue;
                }

                var name     = node.Attr("Name");
                var timeZone = node.Attr("TimeZone");
                var clock    = new ClockViewModel(name)
                {
                    TimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZone)
                };
                clock.Refresh();
                clocks.Add(clock);
            }

            if (clocks.Count == 0)
            {
                Log.TraceMsg("Configuration.ParseClocks: No Clocks loaded");
            }
            else
            {
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    ClocksDisplayViewModel clocksDisplayViewModel;
                    if (oldConfig != null &&
                        oldConfig.Clocks != null)
                    {
                        Log.TraceMsg("Configuration.ParseClocks: Reusing ClocksDisplayViewModel from old config");
                        clocksDisplayViewModel = oldConfig.Clocks;
                        clocksDisplayViewModel.Clocks.Clear();
                    }
                    else
                    {
                        Log.TraceMsg("Configuration.ParseClocks: Creating new ClocksDisplayViewModel");
                        clocksDisplayViewModel = new ClocksDisplayViewModel();
                    }

                    clocksDisplayViewModel.DisplayIntervalInSeconds = interval;
                    clocksDisplayViewModel.Clocks.AddRange(clocks);
                    config.Clocks = clocksDisplayViewModel;
                });

                Log.TraceMsg("Configuration.ParseClocks: {0} Clocks loaded", config.Clocks.Clocks.Count);
            }

            Log.TraceExit();
        }
Example #7
0
        void Handle_Watch_Clicked(object sender, System.EventArgs e)
        {
            var timeModel = new ClockViewModel()
            {
                FullDate = DateTime.Now
            };

            Detail.Content = new ClockView(timeModel);
        }
Example #8
0
        public async Task Clock(ClockViewModel model)
        {
            string requestURL = "/path/{Parameter}";
            var    httpMethod = BaseNetworkAccessEnum.Get;
            var    parameters = new Dictionary <string, object>()
            {
                //{"Parameter", model.Property},
            };

            await _NetworkInterface(requestURL, parameters, httpMethod);
        }
Example #9
0
        public async Task <IActionResult> Index()
        {
            var currentUser = await GetCurrentUserAsync();

            var model = new ClockViewModel()
            {
                User = currentUser
            };

            return(View(model));
        }
Example #10
0
 public MainWindow()
 {
     InitializeComponent();
     // データバインディングを初期化
     clockView        = new ClockViewModel();
     this.DataContext = clockView;
     // 色判定の初期化
     clockWhite = true;
     // タイマー生成
     timer = CreateTimer();
     timer.Start();
 }
Example #11
0
 public async Task <IActionResult> Home()
 {
     if (_clock == null)
     {
         _clock = new ClockViewModel();
         return(View(_clock));
     }
     else
     {
         return(View(_clock));
     }
 }
Example #12
0
        public ClockPage(ClockViewModel vm, bool saveButton)
        {
            InitializeComponent();

            if (!saveButton)
            {
                Title = "Edit Clock";
                this.saveButton.Text = "Edit";
            }
            viewModel      = vm;
            BindingContext = viewModel;
        }
Example #13
0
        public void TestMethod1()
        {
            var cm = new ClockModel();

            cm.Update();
            var cvm = new ClockViewModel();

            cvm.Initialize(cm);
            var cmTest  = cm.CurrentTime;
            var cvmTime = cvm.CurrentTime;

            Assert.AreEqual("7:50", cvmTime);
        }
Example #14
0
        public void ClockViewModelCorrectlyDisplaysAMTime()
        {
            var cm = new MockClockModel();

            cm.MockDateTime = DateTime.Parse("2015-10-30 04:53:13");
            cm.Update();
            var cvm = new ClockViewModel();

            cvm.Initialize(cm);
            var cmTime  = cm.CurrentTime;
            var cvmTime = cvm.CurrentTime;

            Assert.AreEqual("4:53", cvmTime);
        }
Example #15
0
        public async Task <IActionResult> CreateClockDTO(ClockViewModel clockViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }


            _clock = clockViewModel;

            // ClockProcess clockProcess = new ClockProcess();
            // clockProcess.SetDecrementValue(clockViewModel.DecrementSecs);
            //return RedirectToAction(nameof(Decrement), clockViewModel);

            return(RedirectToAction(nameof(Home)));
        }
        public async Task CreateClockDTO()
        {
            var            controller     = new MainController();
            ClockViewModel clockViewModel = new ClockViewModel()
            {
                DecrementSecs = 5
            };
            var result = controller.CreateClockDTO(clockViewModel);

            // if not null then continue, null end
            Assert.IsNotNull(result);

            var viewResult = result.Result;

            //Assert
            Assert.IsTrue(result.Status == TaskStatus.RanToCompletion && ((RedirectToActionResult)viewResult).ActionName == "Home");
        }
        public void ShouldProvideDateTimeToDisplay()
        {
            // Given
            var now   = new DateTimeOffset(2020, 8, 19, 19, 39, 47, TimeSpan.Zero);
            var clock = new Mock <IClock>();

            clock.SetupGet(i => i.Now).Returns(now);

            var viewModel = new ClockViewModel(clock.Object, Mock.Of <ITimer>());

            // When
            var date = viewModel.Date;
            var time = viewModel.Time;

            // Then
            date.ShouldBe(now.ToString("d"));
            time.ShouldBe(now.ToString("T"));
        }
        public void ShouldDisposeTimerSubscriptionWhenDispose()
        {
            // Given
            var subscription = new Mock <IDisposable>();
            var timer        = new Mock <ITimer>();

            timer
            .Setup(i => i.Subscribe(It.IsAny <IObserver <Tick> >()))
            .Returns(subscription.Object);

            var viewModel = new ClockViewModel(Mock.Of <IClock>(), timer.Object);

            // When
            ((IDisposable)viewModel).Dispose();

            // Then
            subscription.Verify(i => i.Dispose(), Times.Once);
        }
Example #19
0
        public ClockWindow(TaskbarRef targetTaskbar, ClockViewModel viewModel)
        // currently we always use the Windows 10 renderer
            : base(targetTaskbar, TaskbarWindowPlacement.LeftOfTray, new ClockComponent(viewModel))
        {
            InitializeComponent();

            ViewModel = viewModel;

            // the tool tip which contains a long version of the day including Weekday
            toolTip           = new ToolTip();
            toolTip.Active    = true;
            toolTip.UseFading = false;

            // we have to show the tooltip manually for correct positioning
            MouseMove  += ClockWindow_MouseMove;
            MouseLeave += ClockWindow_MouseLeave;

            // when clicked, open the calendar flyout
            MouseClick += ClockWindow_MouseClick;
        }
        public void Tick3662Times_CheckAngles()
        {
            using (var shimContext = ShimsContext.Create())
            {
                // arrange
                // Fake the Timer.Start method to prevent timer running in this context
                System.Windows.Threading.Fakes.ShimDispatcherTimer.AllInstances.Start =
                (timer) =>
                {
                    // ignore
                };
                // Capture the Timer.Tick event in the FakeTick event handler
                System.Windows.Threading.Fakes.ShimDispatcherTimer.AllInstances.TickAddEventHandler =
                (timer, evHandler) =>
                {
                    FakeTick += evHandler;
                };
                // Fake the DateTime.Now
                System.Fakes.ShimDateTime.NowGet =
                () =>
                {
                    return new DateTime(2015, 1, 28, 0, 0, 0);
                };

                ClockViewModel cvm = new ClockViewModel();

                // act
                // Invoke the Timer.Tick event through captured event handler
                for (int i = 0; i < 3662; i++)
                {
                    FakeTick(this, new EventArgs());
                }

                // assert
                Assert.AreEqual(cvm.HourAngle, 30.5, "Hours angle not correct");
                Assert.AreEqual(cvm.MinutesAngle, 6, "Minutes angle not correct");
                Assert.AreEqual(cvm.SecondsAngle, 6, "Minutes angle not correct");
            }
        }
        public ClockWindow(TaskbarRef targetTaskbar, ClockViewModel viewModel)
        // currently we always use the Windows 10 renderer
            : base(targetTaskbar, new Win10TaskbarClockRenderer(viewModel))
        {
            InitializeComponent();

            ViewModel = viewModel;

            // redraw the window, when the current time changes
            ViewModel.PropertyChanged += (s, e) => Invalidate();

            // the tool tip which contains a long version of the day including Weekday
            toolTip           = new ToolTip();
            toolTip.Active    = true;
            toolTip.UseFading = false;

            // we have to show the tooltip manually for correct positioning
            MouseMove  += ClockWindow_MouseMove;
            MouseLeave += ClockWindow_MouseLeave;

            // when clicked, open the calendar flyout
            MouseClick += ClockWindow_MouseClick;
        }
        public void ShouldRefreshDateTimeWhenTimerTick()
        {
            // Given
            var timer = new Mock <ITimer>();
            IObserver <Tick> observer = null;

            timer
            .Setup(i => i.Subscribe(It.IsAny <IObserver <Tick> >()))
            .Callback(new Action <IObserver <Tick> >(o => { observer = o; }))
            .Returns(Mock.Of <IDisposable>());

            var viewModel     = new ClockViewModel(Mock.Of <IClock>(), timer.Object);
            var propertyNames = new List <string>();

            viewModel.PropertyChanged += (sender, args) => { propertyNames.Add(args.PropertyName); };

            // When
            observer?.OnNext(Tick.Shared);
            observer?.OnNext(Tick.Shared);

            // Then
            propertyNames.Count(i => i == nameof(IClockViewModel.Date)).ShouldBe(2);
            propertyNames.Count(i => i == nameof(IClockViewModel.Time)).ShouldBe(2);
        }
Example #23
0
 public ClockView(ClockViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Example #24
0
 public async Task <IActionResult> Decrement(ClockViewModel clockViewModel)
 {
     return(View(clockViewModel));
 }
Example #25
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     DataContext = new ClockViewModel();
 }
Example #26
0
 public Win10TaskbarClockRenderer(ClockViewModel viewModel)
 {
     ViewModel = viewModel;
 }
Example #27
0
 public ucClock()
 {
     InitializeComponent();
     DataContext = new ClockViewModel();
 }
 void UpdateClock()
 {
     DataContext = new ClockViewModel(this, GetLocalTime());
 }
Example #29
0
        public async Task Clock(ClockViewModel model, Action completeAction)
        {
            await _Service.Clock(model);

            completeAction();
        }