예제 #1
0
        private void SetText()
        {
            string summary;
            string detailText = string.Empty;

            if (Countdown != null)
            {
                if (Countdown.IsEventOccurring(DateTime.Now))
                {
                    var sc = new StringCreator()
                             .AddParameter(StringParam.EVENT_NAME, Countdown.Title);
                    summary = sc.BuildString(AppResources.EventOccuringNow);
                }
                else
                {
                    summary    = GetSummaryCountdownText();
                    detailText = GetDetailCountdownText();
                }
            }
            else
            {
                summary = AppResources.NoCountdown;
            }
            Dispatcher.BeginInvoke(() => SummaryText.Text = summary);
            Dispatcher.BeginInvoke(() => DetailText.Text  = detailText);

            SecondsToChange--;
            if (SecondsToChange <= 0)
            {
                SetIntervalType();
                ResetSecondsToChange();
            }
        }
예제 #2
0
        public static string GetCountdownText(TimeInterval timeInterval, Countdown countdown, string countdownTemplate)
        {
            var intervalNameCount = Utility.GetIntervalString(timeInterval, countdown);

            string countStr;
            var    count = intervalNameCount.Count;

            if (intervalNameCount.Count % 1 == 0)
            {
                countStr = count.ToString("F0");
            }
            else
            {
                countStr = count.ToString("F2");
            }

            var sc = new StringCreator()
                     .AddParameter(StringParam.INTERVAL_NAME, intervalNameCount.TimeIntervalSub)
                     .AddParameter(StringParam.COUNT, countStr)
                     .AddParameter(StringParam.EVENT_NAME, countdown.Title);

            var summary = sc.BuildString(countdownTemplate);

            return(summary);
        }
예제 #3
0
        private void BuildEvents()
        {
            if (EventsBuilt)
            {
                return;
            }

            var events = Countdown.GetCountdowns().Where(cd => cd.IsEventOccuringOnDay(Date)).ToArray();
            int count  = events.Length;

            var summary = new TextBlock()
            {
                Text = "Event Summary", FontSize = 36
            };
            var row = new RowDefinition();// { Height = new GridLength(summary.Height + 2) };

            ContentPanel.RowDefinitions.Add(row);
            summary.SetValue(Grid.RowProperty, 0);
            ContentPanel.Children.Add(summary);

            if (count > 0)
            {
                var    sc   = new StringCreator().AddParameter(StringParam.COUNT, count);
                string text = sc.BuildString(AppResources.DayEventsSummary);
                summary.Text = text;

                int rowCount = 1;
                foreach (var cd in events)
                {
                    var eventBlock = new TextBlock()
                    {
                        Text = cd.Title, FontSize = 22, Tag = cd
                    };
                    eventBlock.Tap += EventBlock_Tap;
                    var eventRow = new RowDefinition();// { Height = new GridLength(eventBlock.Height + 2) };
                    ContentPanel.RowDefinitions.Add(eventRow);
                    eventBlock.SetValue(Grid.RowProperty, rowCount);
                    ContentPanel.Children.Add(eventBlock);
                    rowCount++;
                }
            }
            else
            {
                summary.Text = AppResources.DayNoEventsSummary;
            }
            EventsBuilt = true;
        }